@salutejs/plasma-new-hope 0.76.3-canary.1180.8720362393.0 → 0.77.0-canary.1185.8720195819.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Avatar/Avatar.js +1 -35
- package/cjs/components/Avatar/Avatar.js.map +1 -1
- package/cjs/components/Combobox/Combobox.css +2 -2
- package/cjs/components/Combobox/ui/ComboboxDivider/ComboboxDivider.css +2 -2
- package/cjs/components/Combobox/ui/ComboboxDivider/ComboboxDivider.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxFooter/ComboboxFooter.css +2 -2
- package/cjs/components/Combobox/ui/ComboboxFooter/ComboboxFooter.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxGroup/ComboboxGroup.css +2 -2
- package/cjs/components/Combobox/ui/ComboboxGroup/ComboboxGroup.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxHeader/ComboboxHeader.css +2 -2
- package/cjs/components/Combobox/ui/ComboboxHeader/ComboboxHeader.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxItem/ComboboxItem.css +2 -2
- package/cjs/components/Combobox/ui/ComboboxItem/ComboboxItem.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxItem/ComboboxItem.styles.js +1 -1
- package/cjs/components/Dropdown/Dropdown.css +2 -2
- package/cjs/components/Dropdown/Dropdown.js +27 -4
- package/cjs/components/Dropdown/Dropdown.js.map +1 -1
- package/cjs/components/Dropdown/Dropdown.styles.js +1 -1
- package/cjs/components/Dropdown/Dropdown.styles.js.map +1 -1
- package/cjs/components/Dropdown/{Dropdown.styles_1daxhqh.css → Dropdown.styles_13400l5.css} +1 -1
- package/cjs/components/Dropdown/Dropdown.tokens.js +1 -0
- package/cjs/components/Dropdown/Dropdown.tokens.js.map +1 -1
- package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +81 -0
- package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -0
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +5 -3
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
- package/cjs/components/Dropdown/utils/index.js +43 -0
- package/cjs/components/Dropdown/utils/index.js.map +1 -1
- package/cjs/components/Pagination/Pagination.css +2 -2
- package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.css +2 -2
- package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.styles.js +1 -1
- package/cjs/components/Select/Select.css +2 -2
- package/cjs/components/Select/ui/SelectDivider/SelectDivider.css +2 -2
- package/cjs/components/Select/ui/SelectDivider/SelectDivider.js +1 -1
- package/cjs/components/Select/ui/SelectFooter/SelectFooter.css +2 -2
- package/cjs/components/Select/ui/SelectFooter/SelectFooter.js +1 -1
- package/cjs/components/Select/ui/SelectGroup/SelectGroup.css +2 -2
- package/cjs/components/Select/ui/SelectGroup/SelectGroup.js +1 -1
- package/cjs/components/Select/ui/SelectHeader/SelectHeader.css +2 -2
- package/cjs/components/Select/ui/SelectHeader/SelectHeader.js +1 -1
- package/cjs/components/Select/ui/SelectItem/SelectItem.css +2 -2
- package/cjs/components/Select/ui/SelectItem/SelectItem.js +1 -1
- package/cjs/components/Select/ui/SelectItem/SelectItem.styles.js +1 -1
- package/cjs/index.css +2 -2
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/es/components/Avatar/Avatar.js +2 -36
- package/es/components/Avatar/Avatar.js.map +1 -1
- package/es/components/Combobox/Combobox.css +2 -2
- package/es/components/Combobox/ui/ComboboxDivider/ComboboxDivider.css +2 -2
- package/es/components/Combobox/ui/ComboboxDivider/ComboboxDivider.js +1 -1
- package/es/components/Combobox/ui/ComboboxFooter/ComboboxFooter.css +2 -2
- package/es/components/Combobox/ui/ComboboxFooter/ComboboxFooter.js +1 -1
- package/es/components/Combobox/ui/ComboboxGroup/ComboboxGroup.css +2 -2
- package/es/components/Combobox/ui/ComboboxGroup/ComboboxGroup.js +1 -1
- package/es/components/Combobox/ui/ComboboxHeader/ComboboxHeader.css +2 -2
- package/es/components/Combobox/ui/ComboboxHeader/ComboboxHeader.js +1 -1
- package/es/components/Combobox/ui/ComboboxItem/ComboboxItem.css +2 -2
- package/es/components/Combobox/ui/ComboboxItem/ComboboxItem.js +1 -1
- package/es/components/Combobox/ui/ComboboxItem/ComboboxItem.styles.js +1 -1
- package/es/components/Dropdown/Dropdown.css +2 -2
- package/es/components/Dropdown/Dropdown.js +29 -6
- package/es/components/Dropdown/Dropdown.js.map +1 -1
- package/es/components/Dropdown/Dropdown.styles.js +1 -1
- package/es/components/Dropdown/Dropdown.styles.js.map +1 -1
- package/es/components/Dropdown/{Dropdown.styles_1daxhqh.css → Dropdown.styles_13400l5.css} +1 -1
- package/es/components/Dropdown/Dropdown.tokens.js +1 -0
- package/es/components/Dropdown/Dropdown.tokens.js.map +1 -1
- package/es/components/Dropdown/hooks/useKeyboardNavigation.js +76 -0
- package/es/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -0
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +5 -3
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
- package/es/components/Dropdown/utils/index.js +45 -3
- package/es/components/Dropdown/utils/index.js.map +1 -1
- package/es/components/Pagination/Pagination.css +2 -2
- package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.css +2 -2
- package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.styles.js +1 -1
- package/es/components/Select/Select.css +2 -2
- package/es/components/Select/ui/SelectDivider/SelectDivider.css +2 -2
- package/es/components/Select/ui/SelectDivider/SelectDivider.js +1 -1
- package/es/components/Select/ui/SelectFooter/SelectFooter.css +2 -2
- package/es/components/Select/ui/SelectFooter/SelectFooter.js +1 -1
- package/es/components/Select/ui/SelectGroup/SelectGroup.css +2 -2
- package/es/components/Select/ui/SelectGroup/SelectGroup.js +1 -1
- package/es/components/Select/ui/SelectHeader/SelectHeader.css +2 -2
- package/es/components/Select/ui/SelectHeader/SelectHeader.js +1 -1
- package/es/components/Select/ui/SelectItem/SelectItem.css +2 -2
- package/es/components/Select/ui/SelectItem/SelectItem.js +1 -1
- package/es/components/Select/ui/SelectItem/SelectItem.styles.js +1 -1
- package/es/index.css +2 -2
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Avatar/Avatar.js +1 -40
- package/styled-components/cjs/components/Avatar/Avatar.template-doc.mdx +2 -52
- package/styled-components/cjs/components/Dropdown/Dropdown.js +28 -6
- package/styled-components/cjs/components/Dropdown/Dropdown.styles.js +1 -1
- package/styled-components/cjs/components/Dropdown/Dropdown.tokens.js +1 -0
- package/styled-components/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +83 -0
- package/styled-components/cjs/components/Dropdown/index.js +9 -1
- package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +5 -3
- package/styled-components/cjs/components/Dropdown/utils/index.js +48 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +1 -26
- package/styled-components/cjs/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx +18 -36
- package/styled-components/cjs/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.config.js +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.stories.tsx +27 -7
- package/styled-components/cjs/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.config.js +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.stories.tsx +30 -11
- package/styled-components/cjs/examples/plasma_web/components/Avatar/Avatar.stories.tsx +1 -26
- package/styled-components/cjs/examples/plasma_web/components/Dropdown/Normal/Dropdown.config.js +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Dropdown/Normal/Dropdown.stories.tsx +27 -8
- package/styled-components/cjs/examples/plasma_web/components/Dropdown/Tight/Dropdown.config.js +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Dropdown/Tight/Dropdown.stories.tsx +30 -11
- package/styled-components/cjs/examples/sds_engineer/components/Avatar/Avatar.stories.tsx +1 -27
- package/styled-components/es/components/Avatar/Avatar.js +1 -41
- package/styled-components/es/components/Avatar/Avatar.template-doc.mdx +2 -52
- package/styled-components/es/components/Dropdown/Dropdown.js +29 -6
- package/styled-components/es/components/Dropdown/Dropdown.styles.js +1 -1
- package/styled-components/es/components/Dropdown/Dropdown.tokens.js +1 -0
- package/styled-components/es/components/Dropdown/hooks/useKeyboardNavigation.js +77 -0
- package/styled-components/es/components/Dropdown/index.js +1 -0
- package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +5 -3
- package/styled-components/es/components/Dropdown/utils/index.js +48 -1
- package/styled-components/es/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +1 -26
- package/styled-components/es/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx +18 -36
- package/styled-components/es/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.config.js +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.stories.tsx +27 -7
- package/styled-components/es/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.config.js +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.stories.tsx +30 -11
- package/styled-components/es/examples/plasma_web/components/Avatar/Avatar.stories.tsx +1 -26
- package/styled-components/es/examples/plasma_web/components/Dropdown/Normal/Dropdown.config.js +1 -1
- package/styled-components/es/examples/plasma_web/components/Dropdown/Normal/Dropdown.stories.tsx +27 -8
- package/styled-components/es/examples/plasma_web/components/Dropdown/Tight/Dropdown.config.js +1 -1
- package/styled-components/es/examples/plasma_web/components/Dropdown/Tight/Dropdown.stories.tsx +30 -11
- package/styled-components/es/examples/sds_engineer/components/Avatar/Avatar.stories.tsx +1 -27
- package/types/components/Avatar/Avatar.d.ts +1 -3
- package/types/components/Avatar/Avatar.d.ts.map +1 -1
- package/types/components/Avatar/Avatar.types.d.ts +0 -7
- package/types/components/Avatar/Avatar.types.d.ts.map +1 -1
- package/types/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/types/components/Dropdown/Dropdown.tokens.d.ts +1 -0
- package/types/components/Dropdown/Dropdown.tokens.d.ts.map +1 -1
- package/types/components/Dropdown/Dropdown.types.d.ts +7 -2
- package/types/components/Dropdown/Dropdown.types.d.ts.map +1 -1
- package/types/components/Dropdown/hooks/useKeyboardNavigation.d.ts +13 -0
- package/types/components/Dropdown/hooks/useKeyboardNavigation.d.ts.map +1 -0
- package/types/components/Dropdown/index.d.ts +1 -0
- package/types/components/Dropdown/index.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownItem/DropdownItem.d.ts.map +1 -1
- package/types/components/Dropdown/utils/index.d.ts +5 -2
- package/types/components/Dropdown/utils/index.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Avatar/Avatar.d.ts +0 -2
- package/types/examples/plasma_b2c/components/Avatar/Avatar.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.config.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.config.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Avatar/Avatar.d.ts +0 -2
- package/types/examples/plasma_web/components/Avatar/Avatar.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Dropdown/Normal/Dropdown.config.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Dropdown/Tight/Dropdown.config.d.ts.map +1 -1
- package/types/examples/sds_engineer/components/Avatar/Avatar.d.ts +0 -1
- package/types/examples/sds_engineer/components/Avatar/Avatar.d.ts.map +1 -1
@@ -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=
|
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: 'Неактивен' }`.
|
@@ -1,13 +1,17 @@
|
|
1
|
-
var _excluded = ["id", "target", "children", "hasArrow", "
|
1
|
+
var _excluded = ["id", "target", "children", "hasArrow", "view", "size", "frame", "onToggle", "className", "isFocusTrapped", "isOpen", "role", "placement", "trigger", "offset", "preventOverflow", "closeOnOverlayClick", "closeOnEsc"];
|
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; }
|
5
|
-
import React, { forwardRef, useRef } from 'react';
|
5
|
+
import React, { Children, forwardRef, useMemo, useRef } from 'react';
|
6
6
|
import { useFocusTrap, useForkRef, useUniqId } from '@salutejs/plasma-core';
|
7
|
+
import { cx } from '../../utils';
|
7
8
|
import { base as viewCSS } from './variations/_view/base';
|
8
9
|
import { base as sizeCSS } from './variations/_size/base';
|
9
10
|
import { StyledDropdown, StyledPopover } from './Dropdown.styles';
|
10
|
-
import { getPlacements } from './utils';
|
11
|
+
import { getChildren, getPlacements } from './utils';
|
12
|
+
import { classes } from './Dropdown.tokens';
|
13
|
+
import { useKeyNavigation } from './hooks/useKeyboardNavigation';
|
14
|
+
|
11
15
|
/**
|
12
16
|
* Выпадающий список без внешнего контроля видимости.
|
13
17
|
*/
|
@@ -17,15 +21,17 @@ export var dropdownRoot = function dropdownRoot(Root) {
|
|
17
21
|
target = _ref.target,
|
18
22
|
children = _ref.children,
|
19
23
|
hasArrow = _ref.hasArrow,
|
20
|
-
role = _ref.role,
|
21
24
|
view = _ref.view,
|
22
25
|
size = _ref.size,
|
23
26
|
frame = _ref.frame,
|
24
27
|
_onToggle = _ref.onToggle,
|
28
|
+
className = _ref.className,
|
25
29
|
_ref$isFocusTrapped = _ref.isFocusTrapped,
|
26
30
|
isFocusTrapped = _ref$isFocusTrapped === void 0 ? true : _ref$isFocusTrapped,
|
27
31
|
_ref$isOpen = _ref.isOpen,
|
28
32
|
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
33
|
+
_ref$role = _ref.role,
|
34
|
+
role = _ref$role === void 0 ? 'listbox' : _ref$role,
|
29
35
|
_ref$placement = _ref.placement,
|
30
36
|
placement = _ref$placement === void 0 ? 'auto' : _ref$placement,
|
31
37
|
_ref$trigger = _ref.trigger,
|
@@ -43,9 +49,24 @@ export var dropdownRoot = function dropdownRoot(Root) {
|
|
43
49
|
var innerId = id || uniqId;
|
44
50
|
var rootRef = useRef(null);
|
45
51
|
var dropdownRef = useRef(null);
|
52
|
+
var itemsRefs = useRef([]);
|
46
53
|
var handleRef = useForkRef(rootRef, outerRootRef);
|
47
54
|
var trapRef = useFocusTrap(isOpen && isFocusTrapped);
|
48
55
|
var dropdownForkRef = useForkRef(dropdownRef, trapRef);
|
56
|
+
var _useKeyNavigation = useKeyNavigation({
|
57
|
+
itemsRefs: itemsRefs,
|
58
|
+
opened: isOpen,
|
59
|
+
updateOpened: _onToggle
|
60
|
+
}),
|
61
|
+
onKeyDownTarget = _useKeyNavigation.onKeyDownTarget;
|
62
|
+
var childrenArray = useMemo(function () {
|
63
|
+
return Children.toArray(children);
|
64
|
+
}, [children]);
|
65
|
+
var childrenMemo = useMemo(function () {
|
66
|
+
return getChildren(childrenArray, {
|
67
|
+
childrenRefs: itemsRefs
|
68
|
+
});
|
69
|
+
}, [childrenArray, isOpen]);
|
49
70
|
return /*#__PURE__*/React.createElement(StyledPopover, {
|
50
71
|
role: role,
|
51
72
|
isOpen: isOpen,
|
@@ -64,12 +85,14 @@ export var dropdownRoot = function dropdownRoot(Root) {
|
|
64
85
|
closeOnOverlayClick: closeOnOverlayClick,
|
65
86
|
closeOnEsc: closeOnEsc,
|
66
87
|
isFocusTrapped: isFocusTrapped,
|
67
|
-
frame: frame
|
88
|
+
frame: frame,
|
89
|
+
onKeyDown: onKeyDownTarget
|
68
90
|
}, /*#__PURE__*/React.createElement(Root, _extends({
|
91
|
+
className: cx(className, classes.dropdownRoot),
|
69
92
|
ref: handleRef,
|
70
93
|
view: view,
|
71
94
|
size: size
|
72
|
-
}, rest), /*#__PURE__*/React.createElement(StyledDropdown, null,
|
95
|
+
}, rest), /*#__PURE__*/React.createElement(StyledDropdown, null, childrenMemo)));
|
73
96
|
});
|
74
97
|
};
|
75
98
|
export var dropdownConfig = {
|
@@ -7,7 +7,7 @@ import { tokens } from './Dropdown.tokens';
|
|
7
7
|
var Popover = /*#__PURE__*/component(popoverConfig);
|
8
8
|
export var StyledPopover = /*#__PURE__*/styled(Popover).withConfig({
|
9
9
|
componentId: "plasma-new-hope__sc-13ezpo5-0"
|
10
|
-
})([".", "{display:block;}"], /*#__PURE__*/String(popoverClasses.target));
|
10
|
+
})([".", ",.", "{display:block;}"], /*#__PURE__*/String(popoverClasses.wrapper), /*#__PURE__*/String(popoverClasses.target));
|
11
11
|
export var StyledDropdown = /*#__PURE__*/styled.div.withConfig({
|
12
12
|
componentId: "plasma-new-hope__sc-13ezpo5-1"
|
13
13
|
})(["box-sizing:border-box;background:var(", ");box-shadow:var(", ");border-radius:var(", ");width:var(", ");height:var(", ");padding:var(", ") var(", ") var(", ") var(", ");"], tokens.background, tokens.boxShadow, tokens.borderRadius, tokens.width, tokens.height, tokens.paddingTop, tokens.paddingRight, tokens.paddingBottom, tokens.paddingLeft);
|
@@ -0,0 +1,77 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
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."); }
|
3
|
+
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); }
|
4
|
+
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; }
|
5
|
+
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; } }
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
7
|
+
import { useCallback, useEffect, useState } from 'react';
|
8
|
+
export var Keys = {
|
9
|
+
Tab: 'Tab',
|
10
|
+
Enter: 'Enter',
|
11
|
+
Escape: 'Escape',
|
12
|
+
ArrowUp: 'ArrowUp',
|
13
|
+
ArrowDown: 'ArrowDown'
|
14
|
+
};
|
15
|
+
export var useKeyNavigation = function useKeyNavigation(_ref) {
|
16
|
+
var itemsRefs = _ref.itemsRefs,
|
17
|
+
opened = _ref.opened,
|
18
|
+
updateOpened = _ref.updateOpened;
|
19
|
+
var _useState = useState(0),
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
21
|
+
selectItemIndex = _useState2[0],
|
22
|
+
setSelectItemIndex = _useState2[1];
|
23
|
+
useEffect(function () {
|
24
|
+
var _itemsRefs$current, _itemsRefs$current$se;
|
25
|
+
if (!opened) {
|
26
|
+
setSelectItemIndex(0);
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
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();
|
30
|
+
}, [opened]);
|
31
|
+
var onKeyDownTarget = useCallback(function (event) {
|
32
|
+
var _focusedItem, _focusedItem2;
|
33
|
+
event.stopPropagation();
|
34
|
+
var code = event.code;
|
35
|
+
var itemsRefsCount = itemsRefs.current.length;
|
36
|
+
var newOpened = opened;
|
37
|
+
var newSelectItemIndex = selectItemIndex;
|
38
|
+
var focusedItem = null;
|
39
|
+
if (code === Keys.Escape || code === Keys.Tab) {
|
40
|
+
newOpened = false;
|
41
|
+
newSelectItemIndex = -1;
|
42
|
+
updateOpened === null || updateOpened === void 0 ? void 0 : updateOpened(newOpened, event);
|
43
|
+
}
|
44
|
+
if (code === Keys.ArrowUp) {
|
45
|
+
var _itemsRefs$current2;
|
46
|
+
newSelectItemIndex = newSelectItemIndex - 1 === -1 ? itemsRefsCount - 1 : newSelectItemIndex - 1;
|
47
|
+
focusedItem = itemsRefs === null || itemsRefs === void 0 ? void 0 : (_itemsRefs$current2 = itemsRefs.current) === null || _itemsRefs$current2 === void 0 ? void 0 : _itemsRefs$current2[newSelectItemIndex];
|
48
|
+
}
|
49
|
+
if (code === Keys.ArrowDown) {
|
50
|
+
var _itemsRefs$current3;
|
51
|
+
newSelectItemIndex = newSelectItemIndex + 1 === itemsRefsCount ? 0 : newSelectItemIndex + 1;
|
52
|
+
focusedItem = itemsRefs === null || itemsRefs === void 0 ? void 0 : (_itemsRefs$current3 = itemsRefs.current) === null || _itemsRefs$current3 === void 0 ? void 0 : _itemsRefs$current3[newSelectItemIndex];
|
53
|
+
}
|
54
|
+
if (code === Keys.Enter) {
|
55
|
+
event.preventDefault();
|
56
|
+
var item = itemsRefs.current[newSelectItemIndex];
|
57
|
+
|
58
|
+
// TODO: #1016
|
59
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
60
|
+
// @ts-ignore
|
61
|
+
if (item !== null && item !== void 0 && item.ariaDisabled) {
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
item === null || item === void 0 ? void 0 : item.click();
|
65
|
+
}
|
66
|
+
setSelectItemIndex(newSelectItemIndex);
|
67
|
+
(_focusedItem = focusedItem) === null || _focusedItem === void 0 ? void 0 : _focusedItem.focus();
|
68
|
+
(_focusedItem2 = focusedItem) === null || _focusedItem2 === void 0 ? void 0 : _focusedItem2.scrollIntoView({
|
69
|
+
behavior: 'smooth',
|
70
|
+
block: 'center',
|
71
|
+
inline: 'center'
|
72
|
+
});
|
73
|
+
}, [opened, selectItemIndex, updateOpened]);
|
74
|
+
return {
|
75
|
+
onKeyDownTarget: onKeyDownTarget
|
76
|
+
};
|
77
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
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); }
|
2
|
-
var _excluded = ["id", "className", "children", "text", "isSelected", "name", "checked", "value", "
|
2
|
+
var _excluded = ["id", "className", "children", "text", "isSelected", "name", "checked", "value", "view", "size", "disabled", "role", "contentLeft", "contentRight", "onSelect", "onClick", "onChange"];
|
3
3
|
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); }
|
4
4
|
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; }
|
5
5
|
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; }
|
@@ -29,10 +29,11 @@ export var dropdownItemRoot = function dropdownItemRoot(Root) {
|
|
29
29
|
name = _ref.name,
|
30
30
|
checked = _ref.checked,
|
31
31
|
value = _ref.value,
|
32
|
-
role = _ref.role,
|
33
32
|
view = _ref.view,
|
34
33
|
size = _ref.size,
|
35
34
|
disabled = _ref.disabled,
|
35
|
+
_ref$role = _ref.role,
|
36
|
+
role = _ref$role === void 0 ? 'option' : _ref$role,
|
36
37
|
ContentLeftComponent = _ref.contentLeft,
|
37
38
|
ContentRightComponent = _ref.contentRight,
|
38
39
|
onSelect = _ref.onSelect,
|
@@ -66,7 +67,7 @@ export var dropdownItemRoot = function dropdownItemRoot(Root) {
|
|
66
67
|
value: value,
|
67
68
|
checked: checked || isSelected,
|
68
69
|
disabled: disabled,
|
69
|
-
tabIndex:
|
70
|
+
tabIndex: -1
|
70
71
|
}, !disabled && {
|
71
72
|
onChange: handleOnChange
|
72
73
|
});
|
@@ -86,6 +87,7 @@ export var dropdownItemRoot = function dropdownItemRoot(Root) {
|
|
86
87
|
ref: outerRootRef,
|
87
88
|
tabIndex: 0,
|
88
89
|
"aria-disabled": disabled,
|
90
|
+
"aria-selected": isSelected,
|
89
91
|
onClick: handleOnClick,
|
90
92
|
"data-value": value
|
91
93
|
}, rest), text ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledContentLeft, null, ContentLeftComponent && ContentLeft), /*#__PURE__*/React.createElement(StyledText, null, text), /*#__PURE__*/React.createElement(StyledContentRight, null, ContentRightComponent && ContentRight)) : children);
|
@@ -1,5 +1,10 @@
|
|
1
|
+
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; }
|
2
|
+
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; }
|
3
|
+
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; }
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
5
|
+
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); }
|
1
6
|
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); }
|
2
|
-
import React, { cloneElement, isValidElement } from 'react';
|
7
|
+
import React, { Children, cloneElement, isValidElement } from 'react';
|
3
8
|
export var getPlacement = function getPlacement(placement) {
|
4
9
|
return "".concat(placement, "-start");
|
5
10
|
};
|
@@ -27,4 +32,46 @@ export var getValidComponent = function getValidComponent(element, props) {
|
|
27
32
|
return /*#__PURE__*/React.createElement(Component, props);
|
28
33
|
}
|
29
34
|
return element;
|
35
|
+
};
|
36
|
+
export var getChildren = function getChildren(children, externalProps) {
|
37
|
+
if (externalProps.childrenRefs) {
|
38
|
+
externalProps.childrenRefs.current = [];
|
39
|
+
}
|
40
|
+
var res = Children.map(children || [], function (child) {
|
41
|
+
var hasValue = ('value' in (child === null || child === void 0 ? void 0 : child.props));
|
42
|
+
var hasTarget = ('target' in (child === null || child === void 0 ? void 0 : child.props));
|
43
|
+
if (! /*#__PURE__*/isValidElement(child) || !hasValue && !hasTarget) {
|
44
|
+
return child;
|
45
|
+
}
|
46
|
+
if (hasTarget) {
|
47
|
+
var _ref = child === null || child === void 0 ? void 0 : child.props,
|
48
|
+
target = _ref.target;
|
49
|
+
if (! /*#__PURE__*/isValidElement(target)) {
|
50
|
+
return child;
|
51
|
+
}
|
52
|
+
var targetProps = _objectSpread(_objectSpread({}, target === null || target === void 0 ? void 0 : target.props), {}, {
|
53
|
+
ref: function ref(element) {
|
54
|
+
var _externalProps$childr;
|
55
|
+
if (externalProps !== null && externalProps !== void 0 && (_externalProps$childr = externalProps.childrenRefs) !== null && _externalProps$childr !== void 0 && _externalProps$childr.current && element) {
|
56
|
+
externalProps.childrenRefs.current.push(element);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
});
|
60
|
+
var updatedTarget = /*#__PURE__*/cloneElement(target, targetProps);
|
61
|
+
var updatedProps = _objectSpread(_objectSpread({}, child === null || child === void 0 ? void 0 : child.props), {}, {
|
62
|
+
target: updatedTarget
|
63
|
+
});
|
64
|
+
return /*#__PURE__*/cloneElement(child, updatedProps);
|
65
|
+
}
|
66
|
+
var props = _objectSpread(_objectSpread({}, child === null || child === void 0 ? void 0 : child.props), {}, {
|
67
|
+
ref: function ref(element) {
|
68
|
+
var _externalProps$childr2;
|
69
|
+
if (externalProps !== null && externalProps !== void 0 && (_externalProps$childr2 = externalProps.childrenRefs) !== null && _externalProps$childr2 !== void 0 && _externalProps$childr2.current && element) {
|
70
|
+
externalProps.childrenRefs.current.push(element);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
});
|
74
|
+
return /*#__PURE__*/cloneElement(child, props);
|
75
|
+
});
|
76
|
+
return res;
|
30
77
|
};
|
@@ -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
|
};
|
package/styled-components/es/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx
CHANGED
@@ -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: (
|
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"
|
44
|
+
<Avatar size="xxl" customText={index + 1} />
|
46
45
|
))}
|
47
46
|
|
48
|
-
{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
|
-
{
|
86
|
-
|
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
|
},
|
package/styled-components/es/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.config.js
CHANGED
@@ -15,7 +15,7 @@ export var config = {
|
|
15
15
|
l: /*#__PURE__*/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, dropdownTokens.itemPaddingTop, dropdownTokens.itemPaddingRight, dropdownTokens.itemPaddingBottom, dropdownTokens.itemPaddingLeft, dropdownTokens.itemBorderRadius, dropdownTokens.itemFontFamily, dropdownTokens.itemFontSize, dropdownTokens.itemFontStyle, dropdownTokens.itemFontWeightBold, dropdownTokens.itemFontLetterSpacing, dropdownTokens.itemFontLineHeight)
|
16
16
|
},
|
17
17
|
view: {
|
18
|
-
"default": /*#__PURE__*/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);"], dropdownTokens.disabledOpacity, dropdownTokens.background, dropdownTokens.boxShadow, dropdownTokens.itemBackground, dropdownTokens.itemBackgroundHover, dropdownTokens.itemBackgroundSelected, dropdownTokens.itemColorSelected, dropdownTokens.itemBackgroundSelectedHover, dropdownTokens.itemColorSelectedHover, dropdownTokens.itemColor)
|
18
|
+
"default": /*#__PURE__*/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);"], dropdownTokens.disabledOpacity, dropdownTokens.focusColor, dropdownTokens.background, dropdownTokens.boxShadow, dropdownTokens.itemBackground, dropdownTokens.itemBackgroundHover, dropdownTokens.itemBackgroundSelected, dropdownTokens.itemColorSelected, dropdownTokens.itemBackgroundSelectedHover, dropdownTokens.itemColorSelectedHover, dropdownTokens.itemColor)
|
19
19
|
}
|
20
20
|
}
|
21
21
|
};
|
package/styled-components/es/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.stories.tsx
CHANGED
@@ -112,10 +112,10 @@ const StoryNormal = (args: StoryDropdownProps) => {
|
|
112
112
|
}
|
113
113
|
};
|
114
114
|
|
115
|
-
const handleSelect = (value: string, text: string) => {
|
115
|
+
const handleSelect = (value: string, text: string, toggleIsOpen: React.Dispatch<React.SetStateAction<boolean>>) => {
|
116
116
|
setSelected(value);
|
117
117
|
onSelect(value, text);
|
118
|
-
|
118
|
+
toggleIsOpen(false);
|
119
119
|
};
|
120
120
|
|
121
121
|
return (
|
@@ -127,34 +127,51 @@ const StoryNormal = (args: StoryDropdownProps) => {
|
|
127
127
|
onToggle={onMainToggle}
|
128
128
|
offset={[Number(skidding), Number(distance)]}
|
129
129
|
placement={placement}
|
130
|
+
role="listbox"
|
130
131
|
{...rest}
|
131
132
|
>
|
132
133
|
{getDropdownItems('item', 6).map((item) => (
|
133
134
|
<DropdownItem
|
134
135
|
key={item.value}
|
135
136
|
isSelected={Boolean(item.value === selected)}
|
136
|
-
onSelect={() => handleSelect(item.value, item.child)}
|
137
|
+
onSelect={() => handleSelect(item.value, item.child, setIsOpen)}
|
137
138
|
onClick={onClick}
|
138
139
|
value={item.value}
|
140
|
+
role="option"
|
139
141
|
>
|
140
142
|
{item.child}
|
141
143
|
</DropdownItem>
|
142
144
|
))}
|
143
145
|
<Dropdown
|
144
|
-
target={
|
146
|
+
target={
|
147
|
+
<DropdownItem
|
148
|
+
contentRight={DisclosureRightIcon}
|
149
|
+
role="option"
|
150
|
+
name="test"
|
151
|
+
text="Nested dropdown"
|
152
|
+
/>
|
153
|
+
}
|
145
154
|
onToggle={(is) => setIsOpenDropdown2(is)}
|
146
155
|
isOpen={isOpenDropdown2}
|
156
|
+
role="listbox"
|
147
157
|
offset={[0, 0]}
|
148
158
|
{...rest}
|
149
159
|
>
|
150
|
-
<DropdownItem
|
160
|
+
<DropdownItem
|
161
|
+
contentRight={StyledCheckbox}
|
162
|
+
role="option"
|
163
|
+
value="checked"
|
164
|
+
onChange={onChange}
|
165
|
+
text="Checkbox"
|
166
|
+
/>
|
151
167
|
{getDropdownItems('nested', 4).map((item) => (
|
152
168
|
<DropdownItem
|
153
169
|
key={item.value}
|
154
170
|
isSelected={Boolean(item.value === selected)}
|
155
|
-
onSelect={() => handleSelect(item.value, item.child)}
|
171
|
+
onSelect={() => handleSelect(item.value, item.child, setIsOpenDropdown2)}
|
156
172
|
onClick={onClick}
|
157
173
|
value={item.value}
|
174
|
+
role="option"
|
158
175
|
>
|
159
176
|
{item.child}
|
160
177
|
</DropdownItem>
|
@@ -165,6 +182,7 @@ const StoryNormal = (args: StoryDropdownProps) => {
|
|
165
182
|
value="1"
|
166
183
|
onChange={onChange}
|
167
184
|
text="Radiobox 1"
|
185
|
+
role="option"
|
168
186
|
/>
|
169
187
|
<DropdownItem
|
170
188
|
contentLeft={StyledRadiobox}
|
@@ -172,14 +190,16 @@ const StoryNormal = (args: StoryDropdownProps) => {
|
|
172
190
|
value="2"
|
173
191
|
onChange={onChange}
|
174
192
|
text="Radiobox 2"
|
193
|
+
role="option"
|
175
194
|
/>
|
176
195
|
</Dropdown>
|
177
196
|
|
178
197
|
<DropdownItem
|
179
198
|
isSelected={selected === 'disabled'}
|
180
|
-
onSelect={() => handleSelect('disabled', 'disabled')}
|
199
|
+
onSelect={() => handleSelect('disabled', 'disabled', setIsOpen)}
|
181
200
|
onClick={onClick}
|
182
201
|
value="disabled"
|
202
|
+
role="option"
|
183
203
|
disabled
|
184
204
|
>
|
185
205
|
disabled
|
package/styled-components/es/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.config.js
CHANGED
@@ -15,7 +15,7 @@ export var config = {
|
|
15
15
|
l: /*#__PURE__*/css(["", ";", ";", ":0.8125rem;", ":1rem;", ":0.8125rem;", ":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, dropdownTokens.itemPaddingTop, dropdownTokens.itemPaddingRight, dropdownTokens.itemPaddingBottom, dropdownTokens.itemPaddingLeft, dropdownTokens.itemBorderRadius, dropdownTokens.itemFontFamily, dropdownTokens.itemFontSize, dropdownTokens.itemFontStyle, dropdownTokens.itemFontWeightBold, dropdownTokens.itemFontLetterSpacing, dropdownTokens.itemFontLineHeight)
|
16
16
|
},
|
17
17
|
view: {
|
18
|
-
"default": /*#__PURE__*/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);"], dropdownTokens.disabledOpacity, dropdownTokens.background, dropdownTokens.boxShadow, dropdownTokens.itemBackground, dropdownTokens.itemBackgroundHover, dropdownTokens.itemBackgroundSelected, dropdownTokens.itemColorSelected, dropdownTokens.itemBackgroundSelectedHover, dropdownTokens.itemColorSelectedHover, dropdownTokens.itemColor)
|
18
|
+
"default": /*#__PURE__*/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);"], dropdownTokens.disabledOpacity, dropdownTokens.focusColor, dropdownTokens.background, dropdownTokens.boxShadow, dropdownTokens.itemBackground, dropdownTokens.itemBackgroundHover, dropdownTokens.itemBackgroundSelected, dropdownTokens.itemColorSelected, dropdownTokens.itemBackgroundSelectedHover, dropdownTokens.itemColorSelectedHover, dropdownTokens.itemColor)
|
19
19
|
}
|
20
20
|
}
|
21
21
|
};
|