@salutejs/plasma-new-hope 0.78.0-canary.1201.8983771283.0 → 0.78.0-canary.1201.8986419693.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/cjs/components/Dropdown/Dropdown.js +2 -2
  2. package/cjs/components/Dropdown/Dropdown.js.map +1 -1
  3. package/cjs/components/Dropdown/hooks/useHashMaps.js +2 -2
  4. package/cjs/components/Dropdown/hooks/useHashMaps.js.map +1 -1
  5. package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +185 -161
  6. package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -1
  7. package/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js +1 -1
  8. package/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js.map +1 -1
  9. package/es/components/Dropdown/Dropdown.js +2 -2
  10. package/es/components/Dropdown/Dropdown.js.map +1 -1
  11. package/es/components/Dropdown/hooks/useHashMaps.js +2 -2
  12. package/es/components/Dropdown/hooks/useHashMaps.js.map +1 -1
  13. package/es/components/Dropdown/hooks/useKeyboardNavigation.js +185 -161
  14. package/es/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -1
  15. package/es/components/Dropdown/ui/DropdownInner/DropdownInner.js +1 -1
  16. package/es/components/Dropdown/ui/DropdownInner/DropdownInner.js.map +1 -1
  17. package/package.json +2 -2
  18. package/styled-components/cjs/components/Dropdown/Dropdown.js +2 -2
  19. package/styled-components/cjs/components/Dropdown/Dropdown.template-doc.mdx +339 -0
  20. package/styled-components/cjs/components/Dropdown/hooks/useHashMaps.js +2 -2
  21. package/styled-components/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +189 -161
  22. package/styled-components/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js +1 -1
  23. package/styled-components/cjs/examples/plasma_web/components/Dropdown/Dropdown.config.js +25 -0
  24. package/styled-components/cjs/examples/plasma_web/components/Dropdown/Dropdown.js +11 -0
  25. package/styled-components/cjs/examples/plasma_web/components/Dropdown/Dropdown.stories.tsx +292 -0
  26. package/styled-components/es/components/Dropdown/Dropdown.js +2 -2
  27. package/styled-components/es/components/Dropdown/Dropdown.template-doc.mdx +339 -0
  28. package/styled-components/es/components/Dropdown/hooks/useHashMaps.js +2 -2
  29. package/styled-components/es/components/Dropdown/hooks/useKeyboardNavigation.js +189 -161
  30. package/styled-components/es/components/Dropdown/ui/DropdownInner/DropdownInner.js +1 -1
  31. package/styled-components/es/examples/plasma_web/components/Dropdown/Dropdown.config.js +19 -0
  32. package/styled-components/es/examples/plasma_web/components/Dropdown/Dropdown.js +5 -0
  33. package/styled-components/es/examples/plasma_web/components/Dropdown/Dropdown.stories.tsx +292 -0
  34. package/types/components/Dropdown/hooks/useKeyboardNavigation.d.ts.map +1 -1
  35. package/types/examples/plasma_web/components/Dropdown/Dropdown.config.d.ts +18 -0
  36. package/types/examples/plasma_web/components/Dropdown/Dropdown.config.d.ts.map +1 -0
  37. package/types/examples/plasma_web/components/Dropdown/Dropdown.d.ts +13 -0
  38. package/types/examples/plasma_web/components/Dropdown/Dropdown.d.ts.map +1 -0
@@ -33,180 +33,208 @@ export var useKeyNavigation = function useKeyNavigation(_ref) {
33
33
  var currentLength = pathMap.get(path === null || path === void 0 ? void 0 : path[path.length - 1]) || 0;
34
34
  var currentIndex = (focusedPath === null || focusedPath === void 0 ? void 0 : focusedPath[focusedPath.length - 1]) || 0;
35
35
  var onKeyDown = function onKeyDown(event) {
36
- var code = event.code;
37
- if (code === keys.ArrowUp) {
38
- if (focusedPath.length) {
39
- if (currentIndex <= 0) {
40
- return;
36
+ switch (event.code) {
37
+ case keys.ArrowUp:
38
+ {
39
+ if (focusedPath.length) {
40
+ if (currentIndex > 0) {
41
+ dispatchFocusedPath({
42
+ type: 'change_last_focus',
43
+ value: currentIndex - 1
44
+ });
45
+ }
46
+ } else {
47
+ dispatchPath({
48
+ type: 'opened_first_level'
49
+ });
50
+ dispatchFocusedPath({
51
+ type: 'set_initial_focus'
52
+ });
53
+ handleGlobalToggle(true, event);
54
+ }
55
+ break;
41
56
  }
42
- dispatchFocusedPath({
43
- type: 'change_last_focus',
44
- value: currentIndex - 1
45
- });
46
- } else {
47
- dispatchPath({
48
- type: 'opened_first_level'
49
- });
50
- dispatchFocusedPath({
51
- type: 'set_initial_focus'
52
- });
53
- handleGlobalToggle(true, event);
54
- }
55
- }
56
- if (code === keys.ArrowDown) {
57
- if (focusedPath.length) {
58
- if (currentIndex + 1 >= currentLength) {
59
- return;
57
+ case keys.ArrowDown:
58
+ {
59
+ if (focusedPath.length) {
60
+ if (currentIndex + 1 < currentLength) {
61
+ dispatchFocusedPath({
62
+ type: 'change_last_focus',
63
+ value: currentIndex + 1
64
+ });
65
+ }
66
+ } else {
67
+ dispatchPath({
68
+ type: 'opened_first_level'
69
+ });
70
+ dispatchFocusedPath({
71
+ type: 'set_initial_focus'
72
+ });
73
+ handleGlobalToggle(true, event);
74
+ }
75
+ break;
60
76
  }
61
- dispatchFocusedPath({
62
- type: 'change_last_focus',
63
- value: currentIndex + 1
64
- });
65
- } else {
66
- dispatchPath({
67
- type: 'opened_first_level'
68
- });
69
- dispatchFocusedPath({
70
- type: 'set_initial_focus'
71
- });
72
- handleGlobalToggle(true, event);
73
- }
74
- }
75
- if (code === keys.ArrowLeft) {
76
- if (focusedPath.length) {
77
- dispatchPath({
78
- type: 'removed_last_level'
79
- });
80
- dispatchFocusedPath({
81
- type: 'return_prev_focus'
82
- });
83
- }
84
- if (focusedPath.length === 1) {
85
- handleGlobalToggle(false, event);
86
- }
87
- }
88
- if (code === keys.ArrowRight) {
89
- if (focusedPath.length) {
90
- var currentItem = getFurtherPath(focusedPath, focusedToValueMap);
91
- if (currentItem !== null && currentItem !== void 0 && currentItem.items) {
92
- dispatchPath({
93
- type: 'added_next_level',
94
- value: currentItem.value.toString()
95
- });
96
- dispatchFocusedPath({
97
- type: 'add_focus',
98
- value: 0
99
- });
77
+ case keys.ArrowLeft:
78
+ {
79
+ if (focusedPath.length) {
80
+ dispatchPath({
81
+ type: 'removed_last_level'
82
+ });
83
+ dispatchFocusedPath({
84
+ type: 'return_prev_focus'
85
+ });
86
+ }
87
+ if (focusedPath.length === 1) {
88
+ handleGlobalToggle(false, event);
89
+ }
90
+ break;
100
91
  }
101
- }
102
- }
103
- if (code === keys.Enter || code === keys.Space) {
104
- event.preventDefault();
105
- if (path[0]) {
106
- var _currentItem = getFurtherPath(focusedPath, focusedToValueMap);
107
- if (_currentItem !== null && _currentItem !== void 0 && _currentItem.disabled || _currentItem !== null && _currentItem !== void 0 && _currentItem.isDisabled) {
108
- return;
92
+ case keys.ArrowRight:
93
+ {
94
+ if (!focusedPath.length) {
95
+ break;
96
+ }
97
+ var currentItem = getFurtherPath(focusedPath, focusedToValueMap);
98
+ if (currentItem !== null && currentItem !== void 0 && currentItem.items) {
99
+ dispatchPath({
100
+ type: 'added_next_level',
101
+ value: currentItem.value.toString()
102
+ });
103
+ dispatchFocusedPath({
104
+ type: 'add_focus',
105
+ value: 0
106
+ });
107
+ }
108
+ break;
109
109
  }
110
- if (_currentItem !== null && _currentItem !== void 0 && _currentItem.items) {
111
- dispatchPath({
112
- type: 'added_next_level',
113
- value: _currentItem.value.toString()
114
- });
115
- dispatchFocusedPath({
116
- type: 'add_focus',
117
- value: 0
118
- });
119
- } else {
120
- if (closeOnSelect) {
121
- handleGlobalToggle(false, event);
110
+ case keys.Enter:
111
+ case keys.Space:
112
+ {
113
+ event.preventDefault();
114
+ if (!path[0]) {
115
+ dispatchPath({
116
+ type: 'opened_first_level'
117
+ });
118
+ dispatchFocusedPath({
119
+ type: 'set_initial_focus'
120
+ });
121
+ break;
122
122
  }
123
- if (onItemSelect && _currentItem) {
124
- onItemSelect(_currentItem, event);
123
+ var _currentItem = getFurtherPath(focusedPath, focusedToValueMap);
124
+ if (_currentItem !== null && _currentItem !== void 0 && _currentItem.disabled || _currentItem !== null && _currentItem !== void 0 && _currentItem.isDisabled) {
125
+ break;
125
126
  }
126
- if (onItemClick && _currentItem) {
127
- onItemClick(_currentItem, event);
127
+ if (_currentItem !== null && _currentItem !== void 0 && _currentItem.items) {
128
+ dispatchPath({
129
+ type: 'added_next_level',
130
+ value: _currentItem.value.toString()
131
+ });
132
+ dispatchFocusedPath({
133
+ type: 'add_focus',
134
+ value: 0
135
+ });
136
+ } else {
137
+ if (closeOnSelect) {
138
+ handleGlobalToggle(false, event);
139
+ }
140
+ if (onItemSelect && _currentItem) {
141
+ onItemSelect(_currentItem, event);
142
+ }
143
+ if (onItemClick && _currentItem) {
144
+ onItemClick(_currentItem, event);
145
+ }
128
146
  }
147
+ break;
129
148
  }
130
- } else {
131
- dispatchPath({
132
- type: 'opened_first_level'
133
- });
134
- dispatchFocusedPath({
135
- type: 'set_initial_focus'
136
- });
137
- }
138
- }
139
- if (code === keys.Tab || code === keys.Escape) {
140
- dispatchFocusedPath({
141
- type: 'reset'
142
- });
143
- dispatchPath({
144
- type: 'reset'
145
- });
146
- handleGlobalToggle(false, event);
147
- }
148
- if (code === keys.Home) {
149
- if (path[0]) {
150
- dispatchFocusedPath({
151
- type: 'change_last_focus',
152
- value: 0
153
- });
154
- } else {
155
- dispatchPath({
156
- type: 'opened_first_level'
157
- });
158
- dispatchFocusedPath({
159
- type: 'set_initial_focus'
160
- });
161
- handleGlobalToggle(true, event);
162
- }
163
- }
164
- if (code === keys.End) {
165
- if (path[0]) {
166
- dispatchFocusedPath({
167
- type: 'change_last_focus',
168
- value: currentLength - 1
169
- });
170
- } else {
171
- dispatchPath({
172
- type: 'opened_first_level'
173
- });
174
- dispatchFocusedPath({
175
- type: 'change_last_focus',
176
- value: (pathMap.get('root') || 0) - 1
177
- });
178
- handleGlobalToggle(true, event);
179
- }
180
- }
181
- if (code === keys.PageUp) {
182
- if (path[0]) {
183
- if (currentIndex <= JUMP_SIZE) {
149
+ case keys.Tab:
150
+ case keys.Escape:
151
+ {
184
152
  dispatchFocusedPath({
185
- type: 'change_last_focus',
186
- value: 0
153
+ type: 'reset'
187
154
  });
188
- } else {
189
- dispatchFocusedPath({
190
- type: 'change_last_focus',
191
- value: currentIndex - JUMP_SIZE
155
+ dispatchPath({
156
+ type: 'reset'
192
157
  });
158
+ handleGlobalToggle(false, event);
159
+ break;
193
160
  }
194
- }
195
- }
196
- if (code === keys.PageDown) {
197
- if (path[0]) {
198
- if (currentLength - currentIndex <= JUMP_SIZE) {
199
- dispatchFocusedPath({
200
- type: 'change_last_focus',
201
- value: currentLength - 1
202
- });
203
- } else {
204
- dispatchFocusedPath({
205
- type: 'change_last_focus',
206
- value: currentIndex + JUMP_SIZE
207
- });
161
+ case keys.Home:
162
+ {
163
+ if (path[0]) {
164
+ dispatchFocusedPath({
165
+ type: 'change_last_focus',
166
+ value: 0
167
+ });
168
+ } else {
169
+ dispatchPath({
170
+ type: 'opened_first_level'
171
+ });
172
+ dispatchFocusedPath({
173
+ type: 'set_initial_focus'
174
+ });
175
+ handleGlobalToggle(true, event);
176
+ }
177
+ break;
178
+ }
179
+ case keys.End:
180
+ {
181
+ if (path[0]) {
182
+ dispatchFocusedPath({
183
+ type: 'change_last_focus',
184
+ value: currentLength - 1
185
+ });
186
+ } else {
187
+ dispatchPath({
188
+ type: 'opened_first_level'
189
+ });
190
+ dispatchFocusedPath({
191
+ type: 'change_last_focus',
192
+ value: (pathMap.get('root') || 0) - 1
193
+ });
194
+ handleGlobalToggle(true, event);
195
+ }
196
+ break;
197
+ }
198
+ case keys.PageUp:
199
+ {
200
+ if (!path[0]) {
201
+ break;
202
+ }
203
+ if (currentIndex <= JUMP_SIZE) {
204
+ dispatchFocusedPath({
205
+ type: 'change_last_focus',
206
+ value: 0
207
+ });
208
+ } else {
209
+ dispatchFocusedPath({
210
+ type: 'change_last_focus',
211
+ value: currentIndex - JUMP_SIZE
212
+ });
213
+ }
214
+ break;
215
+ }
216
+ case keys.PageDown:
217
+ {
218
+ if (!path[0]) {
219
+ break;
220
+ }
221
+ if (currentLength - currentIndex <= JUMP_SIZE) {
222
+ dispatchFocusedPath({
223
+ type: 'change_last_focus',
224
+ value: currentLength - 1
225
+ });
226
+ } else {
227
+ dispatchFocusedPath({
228
+ type: 'change_last_focus',
229
+ value: currentIndex + JUMP_SIZE
230
+ });
231
+ }
232
+ break;
233
+ }
234
+ default:
235
+ {
236
+ break;
208
237
  }
209
- }
210
238
  }
211
239
  };
212
240
  return {
@@ -35,7 +35,7 @@ var DropdownInner = function DropdownInner(_ref) {
35
35
  }
36
36
  };
37
37
  var isCurrentListOpen = path[currentLevel + 1] === item.value.toString();
38
- var listId = "listbox".concat(currentLevel + 2);
38
+ var listId = "tree_level_".concat(currentLevel + 2);
39
39
  var nextLevel = currentLevel + 1;
40
40
  if (item !== null && item !== void 0 && item.items) {
41
41
  return /*#__PURE__*/React.createElement(StyledPopover, {
@@ -0,0 +1,19 @@
1
+ import { css } from 'styled-components';
2
+ import { dropdownTokens } from '../../../../components/Dropdown';
3
+ export var config = {
4
+ defaults: {
5
+ view: 'default',
6
+ size: 'm'
7
+ },
8
+ variations: {
9
+ size: {
10
+ xs: /*#__PURE__*/css(["", ":0.125rem;", ":10rem;", ":0.5rem;", ":0.5625rem;", ":0.5rem;", ":0.5625rem;", ":0.5rem;", ":0.375rem;", ":0.3125rem;", ":0.3125rem;", ":var(--plasma-typo-body-xs-font-family);", ":var(--plasma-typo-body-xs-font-size);", ":var(--plasma-typo-body-xs-font-style);", ":var(--plasma-typo-body-xs-font-weight);", ":var(--plasma-typo-body-xs-letter-spacing);", ":var(--plasma-typo-body-xs-line-height);"], dropdownTokens.padding, dropdownTokens.width, dropdownTokens.borderRadius, dropdownTokens.itemPaddingTop, dropdownTokens.itemPaddingRight, dropdownTokens.itemPaddingBottom, dropdownTokens.itemPaddingLeft, dropdownTokens.itemBorderRadius, dropdownTokens.itemPaddingTopTight, dropdownTokens.itemPaddingBottomTight, dropdownTokens.itemFontFamily, dropdownTokens.itemFontSize, dropdownTokens.itemFontStyle, dropdownTokens.itemFontWeightBold, dropdownTokens.itemFontLetterSpacing, dropdownTokens.itemFontLineHeight),
11
+ s: /*#__PURE__*/css(["", ":0.125rem;", ":12.5rem;", ":0.625rem;", ":0.6875rem;", ":0.75rem;", ":0.6875rem;", ":0.75rem;", ":0.5rem;", ":0.4375rem;", ":0.4375rem;", ":var(--plasma-typo-body-s-font-family);", ":var(--plasma-typo-body-s-font-size);", ":var(--plasma-typo-body-s-font-style);", ":var(--plasma-typo-body-s-font-weight);", ":var(--plasma-typo-body-s-letter-spacing);", ":var(--plasma-typo-body-s-line-height);"], dropdownTokens.padding, dropdownTokens.width, dropdownTokens.borderRadius, dropdownTokens.itemPaddingTop, dropdownTokens.itemPaddingRight, dropdownTokens.itemPaddingBottom, dropdownTokens.itemPaddingLeft, dropdownTokens.itemBorderRadius, dropdownTokens.itemPaddingTopTight, dropdownTokens.itemPaddingBottomTight, dropdownTokens.itemFontFamily, dropdownTokens.itemFontSize, dropdownTokens.itemFontStyle, dropdownTokens.itemFontWeightBold, dropdownTokens.itemFontLetterSpacing, dropdownTokens.itemFontLineHeight),
12
+ m: /*#__PURE__*/css(["", ":0.125rem;", ":15rem;", ":0.75rem;", ":0.875rem;", ":0.875rem;", ":0.875rem;", ":0.875rem;", ":0.625rem;", ":0.625rem;", ":0.625rem;", ":var(--plasma-typo-body-m-font-family);", ":var(--plasma-typo-body-m-font-size);", ":var(--plasma-typo-body-m-font-style);", ":var(--plasma-typo-body-m-font-weight);", ":var(--plasma-typo-body-m-letter-spacing);", ":var(--plasma-typo-body-m-line-height);"], dropdownTokens.padding, dropdownTokens.width, dropdownTokens.borderRadius, dropdownTokens.itemPaddingTop, dropdownTokens.itemPaddingRight, dropdownTokens.itemPaddingBottom, dropdownTokens.itemPaddingLeft, dropdownTokens.itemBorderRadius, dropdownTokens.itemPaddingTopTight, dropdownTokens.itemPaddingBottomTight, dropdownTokens.itemFontFamily, dropdownTokens.itemFontSize, dropdownTokens.itemFontStyle, dropdownTokens.itemFontWeightBold, dropdownTokens.itemFontLetterSpacing, dropdownTokens.itemFontLineHeight),
13
+ l: /*#__PURE__*/css(["", ":0.125rem;", ":17.5rem;", ":0.875rem;", ":1.0625rem;", ":1rem;", ":1.0625rem;", ":1rem;", ":0.75rem;", ":0.8125rem;", ":0.8125rem;", ":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);"], dropdownTokens.padding, dropdownTokens.width, dropdownTokens.borderRadius, dropdownTokens.itemPaddingTop, dropdownTokens.itemPaddingRight, dropdownTokens.itemPaddingBottom, dropdownTokens.itemPaddingLeft, dropdownTokens.itemBorderRadius, dropdownTokens.itemPaddingTopTight, dropdownTokens.itemPaddingBottomTight, dropdownTokens.itemFontFamily, dropdownTokens.itemFontSize, dropdownTokens.itemFontStyle, dropdownTokens.itemFontWeightBold, dropdownTokens.itemFontLetterSpacing, dropdownTokens.itemFontLineHeight)
14
+ },
15
+ view: {
16
+ "default": /*#__PURE__*/css(["", ":0.4;", ":var(--surface-accent);", ":var(--surface-solid-card);", ":var(--shadow-down-soft-s);", ":var(--text-secondary);", ":var(--plasma-colors-transparent);", ":var(--surface-transparent-secondary);", ":var(--text-primary);"], dropdownTokens.disabledOpacity, dropdownTokens.focusColor, dropdownTokens.background, dropdownTokens.boxShadow, dropdownTokens.disclosureIconColor, dropdownTokens.itemBackground, dropdownTokens.itemBackgroundHover, dropdownTokens.itemColor)
17
+ }
18
+ }
19
+ };
@@ -0,0 +1,5 @@
1
+ import { dropdownConfig } from '../../../../components/Dropdown';
2
+ import { component, mergeConfig } from '../../../../engines';
3
+ import { config } from './Dropdown.config';
4
+ var mergedConfig = /*#__PURE__*/mergeConfig(dropdownConfig, config);
5
+ export var Dropdown = /*#__PURE__*/component(mergedConfig);