@salutejs/plasma-new-hope 0.78.0-canary.1201.8967294034.0 → 0.78.0-canary.1201.8969250152.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Dropdown/Dropdown.js +2 -2
- package/cjs/components/Dropdown/Dropdown.js.map +1 -1
- package/cjs/components/Dropdown/hooks/useHashMaps.js +3 -0
- package/cjs/components/Dropdown/hooks/useHashMaps.js.map +1 -1
- package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +43 -20
- package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js +9 -7
- package/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +0 -59
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js.map +1 -1
- package/es/components/Dropdown/Dropdown.js +2 -2
- package/es/components/Dropdown/Dropdown.js.map +1 -1
- package/es/components/Dropdown/hooks/useHashMaps.js +3 -0
- package/es/components/Dropdown/hooks/useHashMaps.js.map +1 -1
- package/es/components/Dropdown/hooks/useKeyboardNavigation.js +43 -21
- package/es/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownInner/DropdownInner.js +9 -7
- package/es/components/Dropdown/ui/DropdownInner/DropdownInner.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +0 -59
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Dropdown/Dropdown.js +2 -2
- package/styled-components/cjs/components/Dropdown/hooks/useHashMaps.js +3 -0
- package/styled-components/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +43 -21
- package/styled-components/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js +9 -7
- package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +0 -60
- package/styled-components/es/components/Dropdown/Dropdown.js +2 -2
- package/styled-components/es/components/Dropdown/hooks/useHashMaps.js +3 -0
- package/styled-components/es/components/Dropdown/hooks/useKeyboardNavigation.js +42 -20
- package/styled-components/es/components/Dropdown/ui/DropdownInner/DropdownInner.js +9 -7
- package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +0 -60
- package/types/components/Dropdown/hooks/useHashMaps.d.ts.map +1 -1
- package/types/components/Dropdown/hooks/useKeyboardNavigation.d.ts +14 -0
- package/types/components/Dropdown/hooks/useKeyboardNavigation.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownInner/DropdownInner.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownItem/DropdownItem.styles.d.ts.map +1 -1
@@ -1,5 +1,8 @@
|
|
1
1
|
import { useMemo } from 'react';
|
2
2
|
|
3
|
+
// Данный хук рекурсивно проходится по дереву items и создаем 2 мапы: мапу путей и мапу фокусов.
|
4
|
+
// Нужно для получения информации всей об item, зная только путь до нее.
|
5
|
+
|
3
6
|
var useHashMaps = function useHashMaps(items) {
|
4
7
|
return useMemo(function () {
|
5
8
|
var pathMap = new Map();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useHashMaps.js","sources":["../../../../src/components/Dropdown/hooks/useHashMaps.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { DropdownProps } from '../Dropdown.types';\nimport { DropdownItemOption } from '../ui/DropdownItem/DropdownItem.type';\n\nexport type PathMapType = Map<string | number, number>;\nexport type FocusedToValueMapType = Map<string, DropdownItemOption>;\n\nexport const useHashMaps = (items: DropdownProps['items']) => {\n return useMemo(() => {\n const pathMap: PathMapType = new Map();\n const focusedToValueMap: FocusedToValueMapType = new Map();\n\n pathMap.set('root', items.length);\n\n const rec = (items: DropdownProps['items'], prevIndex = '') => {\n items.forEach((item: DropdownItemOption, index: number) => {\n const { value, items: innerItems } = item;\n\n const currIndex = `${prevIndex}/${index}`.replace(/^(\\/)/, '');\n focusedToValueMap.set(currIndex, item);\n\n if (innerItems) {\n pathMap.set(value, innerItems.length);\n rec(innerItems, currIndex);\n }\n });\n };\n rec(items);\n\n return [pathMap, focusedToValueMap] as [PathMapType, FocusedToValueMapType];\n }, [items]);\n};\n"],"names":["useHashMaps","items","useMemo","pathMap","Map","focusedToValueMap","set","length","rec","prevIndex","arguments","undefined","forEach","item","index","value","innerItems","currIndex","concat","replace"],"mappings":";;
|
1
|
+
{"version":3,"file":"useHashMaps.js","sources":["../../../../src/components/Dropdown/hooks/useHashMaps.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { DropdownProps } from '../Dropdown.types';\nimport { DropdownItemOption } from '../ui/DropdownItem/DropdownItem.type';\n\nexport type PathMapType = Map<string | number, number>;\nexport type FocusedToValueMapType = Map<string, DropdownItemOption>;\n\n// Данный хук рекурсивно проходится по дереву items и создаем 2 мапы: мапу путей и мапу фокусов.\n// Нужно для получения информации всей об item, зная только путь до нее.\n\nexport const useHashMaps = (items: DropdownProps['items']) => {\n return useMemo(() => {\n const pathMap: PathMapType = new Map();\n const focusedToValueMap: FocusedToValueMapType = new Map();\n\n pathMap.set('root', items.length);\n\n const rec = (items: DropdownProps['items'], prevIndex = '') => {\n items.forEach((item: DropdownItemOption, index: number) => {\n const { value, items: innerItems } = item;\n\n const currIndex = `${prevIndex}/${index}`.replace(/^(\\/)/, '');\n focusedToValueMap.set(currIndex, item);\n\n if (innerItems) {\n pathMap.set(value, innerItems.length);\n rec(innerItems, currIndex);\n }\n });\n };\n rec(items);\n\n return [pathMap, focusedToValueMap] as [PathMapType, FocusedToValueMapType];\n }, [items]);\n};\n"],"names":["useHashMaps","items","useMemo","pathMap","Map","focusedToValueMap","set","length","rec","prevIndex","arguments","undefined","forEach","item","index","value","innerItems","currIndex","concat","replace"],"mappings":";;AAQA;AACA;;IAEaA,WAAW,GAAG,SAAdA,WAAWA,CAAIC,KAA6B,EAAK;EAC1D,OAAOC,OAAO,CAAC,YAAM;AACjB,IAAA,IAAMC,OAAo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|
+
var keys = {
|
3
|
+
Enter: 'Enter',
|
4
|
+
Space: 'Space',
|
5
|
+
Tab: 'Tab',
|
6
|
+
Escape: 'Escape',
|
7
|
+
ArrowLeft: 'ArrowLeft',
|
8
|
+
ArrowRight: 'ArrowRight',
|
9
|
+
ArrowUp: 'ArrowUp',
|
10
|
+
ArrowDown: 'ArrowDown',
|
11
|
+
Home: 'Home',
|
12
|
+
End: 'End',
|
13
|
+
PageUp: 'PageUp',
|
14
|
+
PageDown: 'PageDown'
|
15
|
+
};
|
1
16
|
var getFurtherPath = function getFurtherPath(focusedPath, focusedToValueMap) {
|
2
17
|
var focusedPathAsString = focusedPath.reduce(function (acc, n) {
|
3
18
|
return "".concat(acc, "/").concat(n);
|
@@ -19,12 +34,14 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
19
34
|
var currentIndex = (focusedPath === null || focusedPath === void 0 ? void 0 : focusedPath[focusedPath.length - 1]) || 0;
|
20
35
|
var onKeyDown = function onKeyDown(event) {
|
21
36
|
var code = event.code;
|
22
|
-
if (code ===
|
37
|
+
if (code === keys.ArrowUp) {
|
23
38
|
if (focusedPath.length) {
|
24
|
-
|
39
|
+
if (currentIndex <= 0) {
|
40
|
+
return;
|
41
|
+
}
|
25
42
|
dispatchFocusedPath({
|
26
43
|
type: 'change_last_focus',
|
27
|
-
value:
|
44
|
+
value: currentIndex - 1
|
28
45
|
});
|
29
46
|
} else {
|
30
47
|
dispatchPath({
|
@@ -36,12 +53,14 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
36
53
|
handleGlobalToggle(true, event);
|
37
54
|
}
|
38
55
|
}
|
39
|
-
if (code ===
|
56
|
+
if (code === keys.ArrowDown) {
|
40
57
|
if (focusedPath.length) {
|
41
|
-
|
58
|
+
if (currentIndex + 1 >= currentLength) {
|
59
|
+
return;
|
60
|
+
}
|
42
61
|
dispatchFocusedPath({
|
43
62
|
type: 'change_last_focus',
|
44
|
-
value:
|
63
|
+
value: currentIndex + 1
|
45
64
|
});
|
46
65
|
} else {
|
47
66
|
dispatchPath({
|
@@ -53,7 +72,7 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
53
72
|
handleGlobalToggle(true, event);
|
54
73
|
}
|
55
74
|
}
|
56
|
-
if (code ===
|
75
|
+
if (code === keys.ArrowLeft) {
|
57
76
|
if (focusedPath.length) {
|
58
77
|
dispatchPath({
|
59
78
|
type: 'removed_last_level'
|
@@ -66,7 +85,7 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
66
85
|
handleGlobalToggle(false, event);
|
67
86
|
}
|
68
87
|
}
|
69
|
-
if (code ===
|
88
|
+
if (code === keys.ArrowRight) {
|
70
89
|
if (focusedPath.length) {
|
71
90
|
var currentItem = getFurtherPath(focusedPath, focusedToValueMap);
|
72
91
|
if (currentItem !== null && currentItem !== void 0 && currentItem.items) {
|
@@ -81,11 +100,13 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
81
100
|
}
|
82
101
|
}
|
83
102
|
}
|
84
|
-
if (code ===
|
103
|
+
if (code === keys.Enter || code === keys.Space) {
|
85
104
|
event.preventDefault();
|
86
105
|
if (path[0]) {
|
87
106
|
var _currentItem = getFurtherPath(focusedPath, focusedToValueMap);
|
88
|
-
if (_currentItem !== null && _currentItem !== void 0 && _currentItem.disabled || _currentItem !== null && _currentItem !== void 0 && _currentItem.isDisabled)
|
107
|
+
if (_currentItem !== null && _currentItem !== void 0 && _currentItem.disabled || _currentItem !== null && _currentItem !== void 0 && _currentItem.isDisabled) {
|
108
|
+
return;
|
109
|
+
}
|
89
110
|
if (_currentItem !== null && _currentItem !== void 0 && _currentItem.items) {
|
90
111
|
dispatchPath({
|
91
112
|
type: 'added_next_level',
|
@@ -115,7 +136,7 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
115
136
|
});
|
116
137
|
}
|
117
138
|
}
|
118
|
-
if (code ===
|
139
|
+
if (code === keys.Tab || code === keys.Escape) {
|
119
140
|
dispatchFocusedPath({
|
120
141
|
type: 'reset'
|
121
142
|
});
|
@@ -124,7 +145,7 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
124
145
|
});
|
125
146
|
handleGlobalToggle(false, event);
|
126
147
|
}
|
127
|
-
if (code ===
|
148
|
+
if (code === keys.Home) {
|
128
149
|
if (path[0]) {
|
129
150
|
dispatchFocusedPath({
|
130
151
|
type: 'change_last_focus',
|
@@ -140,7 +161,7 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
140
161
|
handleGlobalToggle(true, event);
|
141
162
|
}
|
142
163
|
}
|
143
|
-
if (code ===
|
164
|
+
if (code === keys.End) {
|
144
165
|
if (path[0]) {
|
145
166
|
dispatchFocusedPath({
|
146
167
|
type: 'change_last_focus',
|
@@ -157,23 +178,24 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
157
178
|
handleGlobalToggle(true, event);
|
158
179
|
}
|
159
180
|
}
|
160
|
-
if (code ===
|
181
|
+
if (code === keys.PageUp) {
|
161
182
|
if (path[0]) {
|
162
|
-
if (currentIndex <=
|
183
|
+
if (currentIndex <= JUMP_SIZE) {
|
163
184
|
dispatchFocusedPath({
|
164
|
-
type: '
|
185
|
+
type: 'change_last_focus',
|
186
|
+
value: 0
|
165
187
|
});
|
166
188
|
} else {
|
167
189
|
dispatchFocusedPath({
|
168
190
|
type: 'change_last_focus',
|
169
|
-
value: currentIndex -
|
191
|
+
value: currentIndex - JUMP_SIZE
|
170
192
|
});
|
171
193
|
}
|
172
194
|
}
|
173
195
|
}
|
174
|
-
if (code ===
|
196
|
+
if (code === keys.PageDown) {
|
175
197
|
if (path[0]) {
|
176
|
-
if (currentLength - currentIndex <=
|
198
|
+
if (currentLength - currentIndex <= JUMP_SIZE) {
|
177
199
|
dispatchFocusedPath({
|
178
200
|
type: 'change_last_focus',
|
179
201
|
value: currentLength - 1
|
@@ -181,7 +203,7 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
181
203
|
} else {
|
182
204
|
dispatchFocusedPath({
|
183
205
|
type: 'change_last_focus',
|
184
|
-
value: currentIndex +
|
206
|
+
value: currentIndex + JUMP_SIZE
|
185
207
|
});
|
186
208
|
}
|
187
209
|
}
|
@@ -192,5 +214,5 @@ var useKeyNavigation = function useKeyNavigation(_ref) {
|
|
192
214
|
};
|
193
215
|
};
|
194
216
|
|
195
|
-
export { useKeyNavigation };
|
217
|
+
export { keys, useKeyNavigation };
|
196
218
|
//# sourceMappingURL=useKeyboardNavigation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useKeyboardNavigation.js","sources":["../../../../src/components/Dropdown/hooks/useKeyboardNavigation.ts"],"sourcesContent":["import { KeyboardEvent } from 'react';\nimport type { Dispatch } from 'react';\n\nimport { PathAction, PathState } from '../reducers/pathReducer';\nimport { FocusedPathAction, FocusedPathState } from '../reducers/focusedPathReducer';\nimport { HandleGlobalToggleType, DropdownProps } from '../Dropdown.types';\n\nimport { PathMapType, FocusedToValueMapType } from './useHashMaps';\n\nconst getFurtherPath = (focusedPath: FocusedPathState, focusedToValueMap: FocusedToValueMapType) => {\n const focusedPathAsString = focusedPath.reduce((acc, n) => `${acc}/${n}`, '').replace(/^(\\/)/, '');\n\n return focusedToValueMap.get(focusedPathAsString);\n};\n\ninterface Props {\n focusedPath: FocusedPathState;\n dispatchFocusedPath: Dispatch<FocusedPathAction>;\n path: PathState;\n dispatchPath: Dispatch<PathAction>;\n pathMap: PathMapType;\n focusedToValueMap: FocusedToValueMapType;\n handleGlobalToggle: HandleGlobalToggleType;\n closeOnSelect: DropdownProps['closeOnSelect'];\n onItemSelect: DropdownProps['onItemSelect'];\n onItemClick: DropdownProps['onItemClick'];\n}\n\ninterface ReturnedProps {\n onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;\n}\n\nexport const useKeyNavigation = ({\n focusedPath,\n dispatchFocusedPath,\n path,\n dispatchPath,\n pathMap,\n focusedToValueMap,\n handleGlobalToggle,\n closeOnSelect,\n onItemSelect,\n onItemClick,\n}: Props): ReturnedProps => {\n const currentLength: number = pathMap.get(path?.[path.length - 1]) || 0;\n const currentIndex: number = focusedPath?.[focusedPath.length - 1] || 0;\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n const { code } = event;\n\n if (code === 'ArrowUp') {\n if (focusedPath.length) {\n const newIndex = currentIndex <= 0 ? currentLength - 1 : currentIndex - 1;\n dispatchFocusedPath({ type: 'change_last_focus', value: newIndex });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'set_initial_focus' });\n handleGlobalToggle(true, event);\n }\n }\n\n if (code === 'ArrowDown') {\n if (focusedPath.length) {\n const newIndex = currentIndex + 1 >= currentLength ? 0 : currentIndex + 1;\n dispatchFocusedPath({ type: 'change_last_focus', value: newIndex });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'set_initial_focus' });\n handleGlobalToggle(true, event);\n }\n }\n\n if (code === 'ArrowLeft') {\n if (focusedPath.length) {\n dispatchPath({ type: 'removed_last_level' });\n dispatchFocusedPath({ type: 'return_prev_focus' });\n }\n\n if (focusedPath.length === 1) {\n handleGlobalToggle(false, event);\n }\n }\n\n if (code === 'ArrowRight') {\n if (focusedPath.length) {\n const currentItem = getFurtherPath(focusedPath, focusedToValueMap);\n\n if (currentItem?.items) {\n dispatchPath({ type: 'added_next_level', value: currentItem.value.toString() });\n dispatchFocusedPath({ type: 'add_focus', value: 0 });\n }\n }\n }\n\n if (code === 'Enter' || code === 'Space') {\n event.preventDefault();\n\n if (path[0]) {\n const currentItem = getFurtherPath(focusedPath, focusedToValueMap);\n\n if (currentItem?.disabled || currentItem?.isDisabled) return;\n\n if (currentItem?.items) {\n dispatchPath({ type: 'added_next_level', value: currentItem.value.toString() });\n dispatchFocusedPath({ type: 'add_focus', value: 0 });\n } else {\n if (closeOnSelect) {\n handleGlobalToggle(false, event);\n }\n\n if (onItemSelect && currentItem) {\n onItemSelect(currentItem, event);\n }\n\n if (onItemClick && currentItem) {\n onItemClick(currentItem, event);\n }\n }\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'set_initial_focus' });\n }\n }\n\n if (code === 'Tab' || code === 'Escape') {\n dispatchFocusedPath({ type: 'reset' });\n dispatchPath({ type: 'reset' });\n\n handleGlobalToggle(false, event);\n }\n\n if (code === 'Home') {\n if (path[0]) {\n dispatchFocusedPath({ type: 'change_last_focus', value: 0 });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'set_initial_focus' });\n\n handleGlobalToggle(true, event);\n }\n }\n\n if (code === 'End') {\n if (path[0]) {\n dispatchFocusedPath({ type: 'change_last_focus', value: currentLength - 1 });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'change_last_focus', value: (pathMap.get('root') || 0) - 1 });\n\n handleGlobalToggle(true, event);\n }\n }\n\n if (code === 'PageUp') {\n if (path[0]) {\n if (currentIndex <= 10) {\n dispatchFocusedPath({ type: 'set_initial_focus' });\n } else {\n dispatchFocusedPath({ type: 'change_last_focus', value: currentIndex - 10 });\n }\n }\n }\n\n if (code === 'PageDown') {\n if (path[0]) {\n if (currentLength - currentIndex <= 10) {\n dispatchFocusedPath({ type: 'change_last_focus', value: currentLength - 1 });\n } else {\n dispatchFocusedPath({ type: 'change_last_focus', value: currentIndex + 10 });\n }\n }\n }\n };\n\n return { onKeyDown };\n};\n"],"names":["getFurtherPath","focusedPath","focusedToValueMap","focusedPathAsString","reduce","acc","n","concat","replace","get","useKeyNavigation","_ref","dispatchFocusedPath","path","dispatchPath","pathMap","handleGlobalToggle","closeOnSelect","onItemSelect","onItemClick","currentLength","length","currentIndex","onKeyDown","event","code","newIndex","type","value","currentItem","items","toString","preventDefault","disabled","isDisabled"],"mappings":"AASA,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,WAA6B,EAAEC,iBAAwC,EAAK;EAChG,IAAMC,mBAAmB,GAAGF,WAAW,CAACG,MAAM,CA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AIC,IAAI,KAAK,QAAQ,EAAE;AACnB,MAAA,IAAIZ,IAAI,CAAC,CAAC,CAAC,EAAE;QACT,IAAIS,YAAY,IAAI,EAAE,EAAE;AACpBV,UAAAA,mBAAmB,CAAC;AAAEe,YAAAA,IAAI,EAAE,mBAAA;AAAoB,WAAC,CAAC,CAAA;AACtD,SAAC,MAAM;AACHf,UAAAA,mBAAmB,CAAC;AAAEe,YAAAA,IAAI,EAAE,mBAAmB;YAAEC,KAAK,EAAEN,YAAY,GAAG,EAAA;AAAG,WAAC,CAAC,CAAA;AAChF,SAAA;AACJ,OAAA;AACJ,KAAA;IAEA,IAAIG,IAAI,KAAK,UAAU,EAAE;AACrB,MAAA,IAAIZ,IAAI,CAAC,CAAC,CAAC,EAAE;AACT,QAAA,IAAIO,aAAa,GAAGE,YAAY,IAAI,EAAE,EAAE;AACpCV,UAAAA,mBAAmB,CAAC;AAAEe,YAAAA,IAAI,EAAE,mBAAmB;YAAEC,KAAK,EAAER,aAAa,GAAG,CAAA;AAAE,WAAC,CAAC,CAAA;AAChF,SAAC,MAAM;AACHR,UAAAA,mBAAmB,CAAC;AAAEe,YAAAA,IAAI,EAAE,mBAAmB;YAAEC,KAAK,EAAEN,YAAY,GAAG,EAAA;AAAG,WAAC,CAAC,CAAA;AAChF,SAAA;AACJ,OAAA;AACJ,KAAA;GACH,CAAA;EAED,OAAO;AAAEC,IAAAA,SAAS,EAATA,SAAAA;GAAW,CAAA;AACxB;;;;"}
|
1
|
+
{"version":3,"file":"useKeyboardNavigation.js","sources":["../../../../src/components/Dropdown/hooks/useKeyboardNavigation.ts"],"sourcesContent":["import { KeyboardEvent } from 'react';\nimport type { Dispatch } from 'react';\n\nimport { PathAction, PathState } from '../reducers/pathReducer';\nimport { FocusedPathAction, FocusedPathState } from '../reducers/focusedPathReducer';\nimport { HandleGlobalToggleType, DropdownProps } from '../Dropdown.types';\n\nimport { PathMapType, FocusedToValueMapType } from './useHashMaps';\n\nconst JUMP_SIZE = 10;\n\nexport const keys = {\n Enter: 'Enter',\n Space: 'Space',\n Tab: 'Tab',\n Escape: 'Escape',\n ArrowLeft: 'ArrowLeft',\n ArrowRight: 'ArrowRight',\n ArrowUp: 'ArrowUp',\n ArrowDown: 'ArrowDown',\n Home: 'Home',\n End: 'End',\n PageUp: 'PageUp',\n PageDown: 'PageDown',\n};\n\nconst getFurtherPath = (focusedPath: FocusedPathState, focusedToValueMap: FocusedToValueMapType) => {\n const focusedPathAsString = focusedPath.reduce((acc, n) => `${acc}/${n}`, '').replace(/^(\\/)/, '');\n\n return focusedToValueMap.get(focusedPathAsString);\n};\n\ninterface Props {\n focusedPath: FocusedPathState;\n dispatchFocusedPath: Dispatch<FocusedPathAction>;\n path: PathState;\n dispatchPath: Dispatch<PathAction>;\n pathMap: PathMapType;\n focusedToValueMap: FocusedToValueMapType;\n handleGlobalToggle: HandleGlobalToggleType;\n closeOnSelect: DropdownProps['closeOnSelect'];\n onItemSelect: DropdownProps['onItemSelect'];\n onItemClick: DropdownProps['onItemClick'];\n}\n\ninterface ReturnedProps {\n onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;\n}\n\nexport const useKeyNavigation = ({\n focusedPath,\n dispatchFocusedPath,\n path,\n dispatchPath,\n pathMap,\n focusedToValueMap,\n handleGlobalToggle,\n closeOnSelect,\n onItemSelect,\n onItemClick,\n}: Props): ReturnedProps => {\n const currentLength: number = pathMap.get(path?.[path.length - 1]) || 0;\n const currentIndex: number = focusedPath?.[focusedPath.length - 1] || 0;\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n const { code } = event;\n\n if (code === keys.ArrowUp) {\n if (focusedPath.length) {\n if (currentIndex <= 0) {\n return;\n }\n\n dispatchFocusedPath({ type: 'change_last_focus', value: currentIndex - 1 });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'set_initial_focus' });\n handleGlobalToggle(true, event);\n }\n }\n\n if (code === keys.ArrowDown) {\n if (focusedPath.length) {\n if (currentIndex + 1 >= currentLength) {\n return;\n }\n\n dispatchFocusedPath({ type: 'change_last_focus', value: currentIndex + 1 });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'set_initial_focus' });\n handleGlobalToggle(true, event);\n }\n }\n\n if (code === keys.ArrowLeft) {\n if (focusedPath.length) {\n dispatchPath({ type: 'removed_last_level' });\n dispatchFocusedPath({ type: 'return_prev_focus' });\n }\n\n if (focusedPath.length === 1) {\n handleGlobalToggle(false, event);\n }\n }\n\n if (code === keys.ArrowRight) {\n if (focusedPath.length) {\n const currentItem = getFurtherPath(focusedPath, focusedToValueMap);\n\n if (currentItem?.items) {\n dispatchPath({ type: 'added_next_level', value: currentItem.value.toString() });\n dispatchFocusedPath({ type: 'add_focus', value: 0 });\n }\n }\n }\n\n if (code === keys.Enter || code === keys.Space) {\n event.preventDefault();\n\n if (path[0]) {\n const currentItem = getFurtherPath(focusedPath, focusedToValueMap);\n\n if (currentItem?.disabled || currentItem?.isDisabled) {\n return;\n }\n\n if (currentItem?.items) {\n dispatchPath({ type: 'added_next_level', value: currentItem.value.toString() });\n dispatchFocusedPath({ type: 'add_focus', value: 0 });\n } else {\n if (closeOnSelect) {\n handleGlobalToggle(false, event);\n }\n\n if (onItemSelect && currentItem) {\n onItemSelect(currentItem, event);\n }\n\n if (onItemClick && currentItem) {\n onItemClick(currentItem, event);\n }\n }\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'set_initial_focus' });\n }\n }\n\n if (code === keys.Tab || code === keys.Escape) {\n dispatchFocusedPath({ type: 'reset' });\n dispatchPath({ type: 'reset' });\n\n handleGlobalToggle(false, event);\n }\n\n if (code === keys.Home) {\n if (path[0]) {\n dispatchFocusedPath({ type: 'change_last_focus', value: 0 });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'set_initial_focus' });\n\n handleGlobalToggle(true, event);\n }\n }\n\n if (code === keys.End) {\n if (path[0]) {\n dispatchFocusedPath({ type: 'change_last_focus', value: currentLength - 1 });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n dispatchFocusedPath({ type: 'change_last_focus', value: (pathMap.get('root') || 0) - 1 });\n\n handleGlobalToggle(true, event);\n }\n }\n\n if (code === keys.PageUp) {\n if (path[0]) {\n if (currentIndex <= JUMP_SIZE) {\n dispatchFocusedPath({ type: 'change_last_focus', value: 0 });\n } else {\n dispatchFocusedPath({ type: 'change_last_focus', value: currentIndex - JUMP_SIZE });\n }\n }\n }\n\n if (code === keys.PageDown) {\n if (path[0]) {\n if (currentLength - currentIndex <= JUMP_SIZE) {\n dispatchFocusedPath({ type: 'change_last_focus', value: currentLength - 1 });\n } else {\n dispatchFocusedPath({ type: 'change_last_focus', value: currentIndex + JUMP_SIZE });\n }\n }\n }\n };\n\n return { onKeyDown };\n};\n"],"names":["JUMP_SIZE","keys","Enter","Space","Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","getFurtherPath","focusedPath","focusedToValueMap","focusedPathAsString","reduce","acc","n","concat","replace","get","useKeyNavigation","_ref","dispatchFocusedPath","path","dispatchPath","pathMap","handleGlobalToggle","closeOnSelect","onItemSelect","onItemClick","currentLength","length","currentIndex","onKeyDown","event","code","type","value","currentItem","items","toString","preventDefault","disabled","isDisabled"],"mappings":"AASA,IAAMA,SAAS,GAAG,EAAE,CAAA;AAEb,IAAMC,IAAI,GAAG;AAChBC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,SAAS,EAAE,WAAW;AACtBC,EAAAA,UAAU,EAAE,YAAY;AACxBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,SAAS,EAAE,WAAW;AACtBC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,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J,KAAA;GACH,CAAA;EAED,OAAO;AAAEqC,IAAAA,SAAS,EAATA,SAAAA;GAAW,CAAA;AACxB;;;;"}
|
@@ -40,6 +40,8 @@ var DropdownInner = function DropdownInner(_ref) {
|
|
40
40
|
}
|
41
41
|
};
|
42
42
|
var isCurrentListOpen = path[currentLevel + 1] === item.value.toString();
|
43
|
+
var listId = "listbox".concat(currentLevel + 2);
|
44
|
+
var nextLevel = currentLevel + 1;
|
43
45
|
if (item !== null && item !== void 0 && item.items) {
|
44
46
|
return /*#__PURE__*/React.createElement(StyledPopover, {
|
45
47
|
isOpen: isCurrentListOpen,
|
@@ -58,26 +60,26 @@ var DropdownInner = function DropdownInner(_ref) {
|
|
58
60
|
onItemClick: onItemClick,
|
59
61
|
variant: variant,
|
60
62
|
hasArrow: hasArrow,
|
61
|
-
ariaControls:
|
63
|
+
ariaControls: listId,
|
62
64
|
ariaExpanded: isCurrentListOpen,
|
63
|
-
|
64
|
-
ariaLevel: currentLevel + 1,
|
65
|
+
ariaLevel: nextLevel,
|
65
66
|
ariaLabel: item.label
|
66
67
|
}),
|
67
68
|
onToggle: handleToggle,
|
68
|
-
isFocusTrapped: false
|
69
|
+
isFocusTrapped: false,
|
70
|
+
preventOverflow: false
|
69
71
|
}, /*#__PURE__*/React.createElement(Ul, {
|
70
72
|
listHeight: listHeight,
|
71
73
|
listOverflow: listOverflow,
|
72
74
|
role: "group",
|
73
|
-
id:
|
75
|
+
id: listId,
|
74
76
|
listWidth: listWidth,
|
75
77
|
isInnerUl: true
|
76
78
|
}, item.items.map(function (innerItem, innerIndex) {
|
77
79
|
return /*#__PURE__*/React.createElement(DropdownInner, {
|
78
|
-
key: "".concat(innerIndex, "/
|
80
|
+
key: "".concat(innerIndex, "/").concat(currentLevel),
|
79
81
|
item: innerItem,
|
80
|
-
currentLevel:
|
82
|
+
currentLevel: nextLevel,
|
81
83
|
focusedPath: focusedPath,
|
82
84
|
path: path,
|
83
85
|
dispatchPath: dispatchPath,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DropdownInner.js","sources":["../../../../../src/components/Dropdown/ui/DropdownInner/DropdownInner.tsx"],"sourcesContent":["import React from 'react';\nimport type { FC } from 'react';\n\nimport { DropdownItem } from '..';\nimport { Ul, StyledPopover } from '../../Dropdown.styles';\n\nimport { DropdownInnerProps } from './DropdownInner.type';\n\nconst DropdownInner: FC<DropdownInnerProps> = ({\n item,\n currentLevel,\n focusedPath,\n path,\n dispatchPath,\n index,\n trigger,\n itemRole,\n listHeight,\n listOverflow,\n handleGlobalToggle,\n closeOnSelect,\n onHover,\n onItemSelect,\n onItemClick,\n listWidth,\n variant,\n hasArrow,\n}) => {\n const handleToggle = (opened: boolean): void => {\n if (opened) {\n dispatchPath({ type: 'changed_on_level', value: item.value.toString(), level: currentLevel + 1 });\n } else {\n dispatchPath({ type: 'cut_by_level', level: currentLevel + 1 });\n }\n };\n\n const isCurrentListOpen = path[currentLevel + 1] === item.value.toString();\n\n if (item?.items) {\n return (\n <StyledPopover\n isOpen={isCurrentListOpen}\n usePortal={false}\n placement=\"right-start\"\n trigger={trigger}\n target={\n <DropdownItem\n item={item}\n index={index}\n path={path}\n focusedPath={focusedPath}\n currentLevel={currentLevel}\n itemRole={itemRole}\n onHover={onHover}\n onItemSelect={onItemSelect}\n onItemClick={onItemClick}\n variant={variant}\n hasArrow={hasArrow}\n ariaControls={
|
1
|
+
{"version":3,"file":"DropdownInner.js","sources":["../../../../../src/components/Dropdown/ui/DropdownInner/DropdownInner.tsx"],"sourcesContent":["import React from 'react';\nimport type { FC } from 'react';\n\nimport { DropdownItem } from '..';\nimport { Ul, StyledPopover } from '../../Dropdown.styles';\n\nimport { DropdownInnerProps } from './DropdownInner.type';\n\nconst DropdownInner: FC<DropdownInnerProps> = ({\n item,\n currentLevel,\n focusedPath,\n path,\n dispatchPath,\n index,\n trigger,\n itemRole,\n listHeight,\n listOverflow,\n handleGlobalToggle,\n closeOnSelect,\n onHover,\n onItemSelect,\n onItemClick,\n listWidth,\n variant,\n hasArrow,\n}) => {\n const handleToggle = (opened: boolean): void => {\n if (opened) {\n dispatchPath({ type: 'changed_on_level', value: item.value.toString(), level: currentLevel + 1 });\n } else {\n dispatchPath({ type: 'cut_by_level', level: currentLevel + 1 });\n }\n };\n\n const isCurrentListOpen = path[currentLevel + 1] === item.value.toString();\n\n const listId = `listbox${currentLevel + 2}`;\n const nextLevel = currentLevel + 1;\n\n if (item?.items) {\n return (\n <StyledPopover\n isOpen={isCurrentListOpen}\n usePortal={false}\n placement=\"right-start\"\n trigger={trigger}\n target={\n <DropdownItem\n item={item}\n index={index}\n path={path}\n focusedPath={focusedPath}\n currentLevel={currentLevel}\n itemRole={itemRole}\n onHover={onHover}\n onItemSelect={onItemSelect}\n onItemClick={onItemClick}\n variant={variant}\n hasArrow={hasArrow}\n ariaControls={listId}\n ariaExpanded={isCurrentListOpen}\n ariaLevel={nextLevel}\n ariaLabel={item.label}\n />\n }\n onToggle={handleToggle}\n isFocusTrapped={false}\n preventOverflow={false}\n >\n <Ul\n listHeight={listHeight}\n listOverflow={listOverflow}\n role=\"group\"\n id={listId}\n listWidth={listWidth}\n isInnerUl\n >\n {item.items.map((innerItem, innerIndex) => (\n <DropdownInner\n key={`${innerIndex}/${currentLevel}`}\n item={innerItem}\n currentLevel={nextLevel}\n focusedPath={focusedPath}\n path={path}\n dispatchPath={dispatchPath}\n index={innerIndex}\n trigger={trigger}\n itemRole={itemRole}\n listHeight={listHeight}\n listOverflow={listOverflow}\n handleGlobalToggle={handleGlobalToggle}\n closeOnSelect={closeOnSelect}\n onHover={onHover}\n onItemSelect={onItemSelect}\n onItemClick={onItemClick}\n listWidth={listWidth}\n variant={variant}\n hasArrow={hasArrow}\n />\n ))}\n </Ul>\n </StyledPopover>\n );\n }\n\n return (\n <DropdownItem\n item={item}\n index={index}\n focusedPath={focusedPath}\n currentLevel={currentLevel}\n itemRole={itemRole}\n handleGlobalToggle={handleGlobalToggle}\n closeOnSelect={closeOnSelect}\n onHover={onHover}\n onItemSelect={onItemSelect}\n onItemClick={onItemClick}\n variant={variant}\n />\n );\n};\n\nexport { DropdownInner };\n"],"names":["DropdownInner","_ref","item","currentLevel","focusedPath","path","dispatchPath","index","trigger","itemRole","listHeight","listOverflow","handleGlobalToggle","closeOnSelect","onHover","onItemSelect","onItemClick","listWidth","variant","hasArrow","handleToggle","opened","type","value","toString","level","isCurrentListOpen","listId","concat","nextLevel","items","React","createElement","StyledPopover","isOpen","usePortal","placement","target","DropdownItem","ariaControls","ariaExpanded","ariaLevel","ariaLabel","label","onToggle","isFocusTrapped","preventOverflow","Ul","role","id","isInnerUl","map","innerItem","innerIndex","key"],"mappings":";;;;;;;;AAQA,IAAMA,aAAqC,GAAG,SAAxCA,aAAqCA,CAAAC,IAAA,EAmBrC;AAAA,EAAA,IAlBFC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,YAAY,GAAAF,IAAA,CAAZE,YAAY;IACZC,WAAW,GAAAH,IAAA,CAAXG,WAAW;IACXC,IAAI,GAAAJ,IAAA,CAAJI,IAAI;IACJC,YAAY,GAAAL,IAAA,CAAZK,YAAY;IACZC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IACPC,QAAQ,GAAAR,IAAA,CAARQ,QAAQ;IACRC,UAAU,GAAAT,IAAA,CAAVS,UAAU;IACVC,YAAY,GAAAV,IAAA,CAAZU,YAAY;IACZC,kBAAkB,GAAAX,IAAA,CAAlBW,kBAAkB;IAClBC,aAAa,GAAAZ,IAAA,CAAbY,aAAa;IACbC,OAAO,GAAAb,IAAA,CAAPa,OAAO;IACPC,YAAY,GAAAd,IAAA,CAAZc,YAAY;IACZC,WAAW,GAAAf,IAAA,CAAXe,WAAW;IACXC,SAAS,GAAAhB,IAAA,CAATgB,SAAS;IACTC,OAAO,GAAAjB,IAAA,CAAPiB,OAAO;IACPC,QAAQ,GAAAlB,IAAA,CAARkB,QAAQ,CAAA;AAER,EAAA,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ACnBC,QAAAA,UAAU,EAAEA,UAAW;AACvBC,QAAAA,YAAY,EAAEA,YAAa;AAC3BC,QAAAA,kBAAkB,EAAEA,kBAAmB;AACvCC,QAAAA,aAAa,EAAEA,aAAc;AAC7BC,QAAAA,OAAO,EAAEA,OAAQ;AACjBC,QAAAA,YAAY,EAAEA,YAAa;AAC3BC,QAAAA,WAAW,EAAEA,WAAY;AACzBC,QAAAA,SAAS,EAAEA,SAAU;AACrBC,QAAAA,OAAO,EAAEA,OAAQ;AACjBC,QAAAA,QAAQ,EAAEA,QAAAA;AAAS,OACtB,CAAC,CAAA;KACL,CACD,CACO,CAAC,CAAA;AAExB,GAAA;AAEA,EAAA,oBACIY,KAAA,CAAAC,aAAA,CAACM,YAAY,EAAA;AACTpC,IAAAA,IAAI,EAAEA,IAAK;AACXK,IAAAA,KAAK,EAAEA,KAAM;AACbH,IAAAA,WAAW,EAAEA,WAAY;AACzBD,IAAAA,YAAY,EAAEA,YAAa;AAC3BM,IAAAA,QAAQ,EAAEA,QAAS;AACnBG,IAAAA,kBAAkB,EAAEA,kBAAmB;AACvCC,IAAAA,aAAa,EAAEA,aAAc;AAC7BC,IAAAA,OAAO,EAAEA,OAAQ;AACjBC,IAAAA,YAAY,EAAEA,YAAa;AAC3BC,IAAAA,WAAW,EAAEA,WAAY;AACzBE,IAAAA,OAAO,EAAEA,OAAAA;AAAQ,GACpB,CAAC,CAAA;AAEV;;;;"}
|
@@ -22,65 +22,6 @@ var StyledText = /*#__PURE__*/styled('div')({
|
|
22
22
|
"class": "soib72h",
|
23
23
|
propsAsIs: false
|
24
24
|
});
|
25
|
-
|
26
|
-
// TODO: Remove baseContent after refactoring a Select component
|
27
|
-
// export const baseContent = `
|
28
|
-
// box-sizing: content-box;
|
29
|
-
// display: flex;
|
30
|
-
// align-items: center;
|
31
|
-
// user-select: none;
|
32
|
-
//
|
33
|
-
// :focus {
|
34
|
-
// outline: none;
|
35
|
-
// }
|
36
|
-
//
|
37
|
-
// ${addFocus({
|
38
|
-
// outlineSize: '0.0625rem',
|
39
|
-
// outlineOffset: '0',
|
40
|
-
// outlineColor: `var(${tokens.focusColor})`,
|
41
|
-
// outlineRadius: `var(${tokens.itemBorderRadius})`,
|
42
|
-
// hasTransition: false,
|
43
|
-
// customFocusRules: `
|
44
|
-
// &.${classes.dropdownItemIsFocused}:before {
|
45
|
-
// outline: none;
|
46
|
-
// box-shadow: 0 0 0 0.0625rem var(${tokens.focusColor});
|
47
|
-
// }
|
48
|
-
// `,
|
49
|
-
// })};
|
50
|
-
//
|
51
|
-
// width: 100%;
|
52
|
-
//
|
53
|
-
// font-family: var(${tokens.itemFontFamily});
|
54
|
-
// font-size: var(${tokens.itemFontSize});
|
55
|
-
// font-style: var(${tokens.itemFontStyle});
|
56
|
-
// font-weight: var(${tokens.itemFontWeightBold});
|
57
|
-
// letter-spacing: var(${tokens.itemFontLetterSpacing});
|
58
|
-
// line-height: var(${tokens.itemFontLineHeight});
|
59
|
-
//
|
60
|
-
// background: var(${tokens.itemBackground});
|
61
|
-
// color: var(${tokens.itemColor});
|
62
|
-
// border-radius: var(${tokens.itemBorderRadius});
|
63
|
-
//
|
64
|
-
// padding: var(${tokens.itemPaddingTop}) var(${tokens.itemPaddingRight}) var(${tokens.itemPaddingBottom}) var(${
|
65
|
-
// tokens.itemPaddingLeft
|
66
|
-
// });
|
67
|
-
//
|
68
|
-
// margin: 0;
|
69
|
-
//
|
70
|
-
// &:hover:not(.${classes.dropdownItemIsDisabled}) {
|
71
|
-
// cursor: pointer;
|
72
|
-
// background: var(${tokens.itemBackgroundHover});
|
73
|
-
// }
|
74
|
-
//
|
75
|
-
// &.${classes.dropdownItemIsActive} {
|
76
|
-
// background: var(${tokens.itemBackgroundHover});
|
77
|
-
// }
|
78
|
-
//
|
79
|
-
// &.${classes.dropdownItemIsDisabled} {
|
80
|
-
// opacity: var(${tokens.disabledOpacity});
|
81
|
-
// cursor: not-allowed;
|
82
|
-
// }
|
83
|
-
// `;
|
84
25
|
var _exp3 = function _exp3() {
|
85
26
|
return function (_ref) {
|
86
27
|
var variant = _ref.variant;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DropdownItem.styles.js","sources":["../../../../../src/components/Dropdown/ui/DropdownItem/DropdownItem.styles.ts"],"sourcesContent":["import { styled } from '@linaria/react';\n\nimport { classes, tokens } from '../../Dropdown.tokens';\nimport { addFocus, applyEllipsis } from '../../../../mixins';\nimport { DropdownProps } from '../../Dropdown.types';\n\nexport const StyledContentLeft = styled.div`\n display: inline-flex;\n`;\n\nexport const StyledContentRight = styled.div`\n margin-left: auto;\n display: inline-flex;\n`;\n\nexport const DisclosureIconWrapper = styled.div`\n line-height: 0;\n color: var(${tokens.disclosureIconColor});\n`;\n\nexport const StyledText = styled.div`\n ${applyEllipsis()};\n flex: 1;\n`;\n\
|
1
|
+
{"version":3,"file":"DropdownItem.styles.js","sources":["../../../../../src/components/Dropdown/ui/DropdownItem/DropdownItem.styles.ts"],"sourcesContent":["import { styled } from '@linaria/react';\n\nimport { classes, tokens } from '../../Dropdown.tokens';\nimport { addFocus, applyEllipsis } from '../../../../mixins';\nimport { DropdownProps } from '../../Dropdown.types';\n\nexport const StyledContentLeft = styled.div`\n display: inline-flex;\n`;\n\nexport const StyledContentRight = styled.div`\n margin-left: auto;\n display: inline-flex;\n`;\n\nexport const DisclosureIconWrapper = styled.div`\n line-height: 0;\n color: var(${tokens.disclosureIconColor});\n`;\n\nexport const StyledText = styled.div`\n ${applyEllipsis()};\n flex: 1;\n`;\n\nexport const Wrapper = styled.li<{ variant: DropdownProps['variant'] }>`\n display: flex;\n align-items: center;\n margin: 0;\n box-sizing: content-box;\n padding-top: ${({ variant }) => `var(${variant === 'tight' ? tokens.itemPaddingTopTight : tokens.itemPaddingTop})`};\n padding-right: var(${tokens.itemPaddingRight});\n padding-bottom: ${({ variant }) =>\n `var(${variant === 'tight' ? tokens.itemPaddingBottomTight : tokens.itemPaddingBottom})`};\n padding-left: var(${tokens.itemPaddingLeft});\n font-family: var(${tokens.itemFontFamily});\n font-size: var(${tokens.itemFontSize});\n font-style: var(${tokens.itemFontStyle});\n font-weight: var(${tokens.itemFontWeightBold});\n letter-spacing: var(${tokens.itemFontLetterSpacing});\n line-height: var(${tokens.itemFontLineHeight});\n background: var(${tokens.itemBackground});\n color: var(${tokens.itemColor});\n border-radius: var(${tokens.itemBorderRadius});\n user-select: none;\n\n &:hover:not(.${classes.dropdownItemIsDisabled}) {\n cursor: pointer;\n background: var(${tokens.itemBackgroundHover});\n }\n\n &.${classes.dropdownItemIsActive} {\n background: var(${tokens.itemBackgroundHover});\n }\n\n &.${classes.dropdownItemIsDisabled} {\n opacity: var(${tokens.disabledOpacity});\n cursor: not-allowed;\n }\n\n :focus {\n outline: none;\n }\n\n ${addFocus({\n outlineSize: '0.0625rem',\n outlineOffset: '0',\n outlineColor: `var(${tokens.focusColor})`,\n outlineRadius: `var(${tokens.itemBorderRadius})`,\n hasTransition: false,\n customFocusRules: `\n &.${classes.dropdownItemIsFocused}:before {\n outline: none;\n box-shadow: 0 0 0 0.0625rem var(${tokens.focusColor});\n }\n `,\n })};\n`;\n"],"names":["StyledContentLeft","styled","name","class","propsAsIs","StyledContentRight","DisclosureIconWrapper","StyledText","_exp3","_ref","variant","tokens","itemPaddingTopTight","itemPaddingTop","_exp5","_ref2","itemPaddingBottomTight","itemPaddingBottom","Wrapper","vars"],"mappings":";;;AAMO,IAAMA,iBAAiB,gBAAGC,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,mBAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAEtC,EAAA;AAEM,IAAMC,kBAAkB,gBAAGJ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,oBAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAGvC,EAAA;AAEM,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AA,CAAA;AAAA,IAAA,WAAA,EAAA,cAEhGM,KAC0E,EAAA,CAAA;AAAA,GAAA;AAAA,CA4C/F;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.78.0-canary.1201.
|
3
|
+
"version": "0.78.0-canary.1201.8969250152.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -102,5 +102,5 @@
|
|
102
102
|
"react-popper": "2.3.0",
|
103
103
|
"storeon": "3.1.5"
|
104
104
|
},
|
105
|
-
"gitHead": "
|
105
|
+
"gitHead": "2757004741475978cca9ee5537a837fddac808fb"
|
106
106
|
}
|
@@ -132,10 +132,10 @@ var dropdownRoot = exports.dropdownRoot = function dropdownRoot(Root) {
|
|
132
132
|
role: 'combobox',
|
133
133
|
'aria-controls': 'listbox1',
|
134
134
|
'aria-expanded': isCurrentListOpen,
|
135
|
-
'aria-haspopup': 'listbox',
|
136
135
|
'aria-activedescendant': getActiveDescendant(),
|
137
136
|
onKeyDown: onKeyDown
|
138
|
-
})
|
137
|
+
}),
|
138
|
+
preventOverflow: false
|
139
139
|
}, /*#__PURE__*/_react["default"].createElement(_Dropdown.Ul, {
|
140
140
|
listHeight: listHeight,
|
141
141
|
listOverflow: listOverflow,
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.useHashMaps = void 0;
|
7
7
|
var _react = /*#__PURE__*/require("react");
|
8
|
+
// Данный хук рекурсивно проходится по дереву items и создаем 2 мапы: мапу путей и мапу фокусов.
|
9
|
+
// Нужно для получения информации всей об item, зная только путь до нее.
|
10
|
+
|
8
11
|
var useHashMaps = exports.useHashMaps = function useHashMaps(items) {
|
9
12
|
return (0, _react.useMemo)(function () {
|
10
13
|
var pathMap = new Map();
|
@@ -3,7 +3,22 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.useKeyNavigation = void 0;
|
6
|
+
exports.useKeyNavigation = exports.keys = void 0;
|
7
|
+
var JUMP_SIZE = 10;
|
8
|
+
var keys = exports.keys = {
|
9
|
+
Enter: 'Enter',
|
10
|
+
Space: 'Space',
|
11
|
+
Tab: 'Tab',
|
12
|
+
Escape: 'Escape',
|
13
|
+
ArrowLeft: 'ArrowLeft',
|
14
|
+
ArrowRight: 'ArrowRight',
|
15
|
+
ArrowUp: 'ArrowUp',
|
16
|
+
ArrowDown: 'ArrowDown',
|
17
|
+
Home: 'Home',
|
18
|
+
End: 'End',
|
19
|
+
PageUp: 'PageUp',
|
20
|
+
PageDown: 'PageDown'
|
21
|
+
};
|
7
22
|
var getFurtherPath = function getFurtherPath(focusedPath, focusedToValueMap) {
|
8
23
|
var focusedPathAsString = focusedPath.reduce(function (acc, n) {
|
9
24
|
return "".concat(acc, "/").concat(n);
|
@@ -25,12 +40,14 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
25
40
|
var currentIndex = (focusedPath === null || focusedPath === void 0 ? void 0 : focusedPath[focusedPath.length - 1]) || 0;
|
26
41
|
var onKeyDown = function onKeyDown(event) {
|
27
42
|
var code = event.code;
|
28
|
-
if (code ===
|
43
|
+
if (code === keys.ArrowUp) {
|
29
44
|
if (focusedPath.length) {
|
30
|
-
|
45
|
+
if (currentIndex <= 0) {
|
46
|
+
return;
|
47
|
+
}
|
31
48
|
dispatchFocusedPath({
|
32
49
|
type: 'change_last_focus',
|
33
|
-
value:
|
50
|
+
value: currentIndex - 1
|
34
51
|
});
|
35
52
|
} else {
|
36
53
|
dispatchPath({
|
@@ -42,12 +59,14 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
42
59
|
handleGlobalToggle(true, event);
|
43
60
|
}
|
44
61
|
}
|
45
|
-
if (code ===
|
62
|
+
if (code === keys.ArrowDown) {
|
46
63
|
if (focusedPath.length) {
|
47
|
-
|
64
|
+
if (currentIndex + 1 >= currentLength) {
|
65
|
+
return;
|
66
|
+
}
|
48
67
|
dispatchFocusedPath({
|
49
68
|
type: 'change_last_focus',
|
50
|
-
value:
|
69
|
+
value: currentIndex + 1
|
51
70
|
});
|
52
71
|
} else {
|
53
72
|
dispatchPath({
|
@@ -59,7 +78,7 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
59
78
|
handleGlobalToggle(true, event);
|
60
79
|
}
|
61
80
|
}
|
62
|
-
if (code ===
|
81
|
+
if (code === keys.ArrowLeft) {
|
63
82
|
if (focusedPath.length) {
|
64
83
|
dispatchPath({
|
65
84
|
type: 'removed_last_level'
|
@@ -72,7 +91,7 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
72
91
|
handleGlobalToggle(false, event);
|
73
92
|
}
|
74
93
|
}
|
75
|
-
if (code ===
|
94
|
+
if (code === keys.ArrowRight) {
|
76
95
|
if (focusedPath.length) {
|
77
96
|
var currentItem = getFurtherPath(focusedPath, focusedToValueMap);
|
78
97
|
if (currentItem !== null && currentItem !== void 0 && currentItem.items) {
|
@@ -87,11 +106,13 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
87
106
|
}
|
88
107
|
}
|
89
108
|
}
|
90
|
-
if (code ===
|
109
|
+
if (code === keys.Enter || code === keys.Space) {
|
91
110
|
event.preventDefault();
|
92
111
|
if (path[0]) {
|
93
112
|
var _currentItem = getFurtherPath(focusedPath, focusedToValueMap);
|
94
|
-
if (_currentItem !== null && _currentItem !== void 0 && _currentItem.disabled || _currentItem !== null && _currentItem !== void 0 && _currentItem.isDisabled)
|
113
|
+
if (_currentItem !== null && _currentItem !== void 0 && _currentItem.disabled || _currentItem !== null && _currentItem !== void 0 && _currentItem.isDisabled) {
|
114
|
+
return;
|
115
|
+
}
|
95
116
|
if (_currentItem !== null && _currentItem !== void 0 && _currentItem.items) {
|
96
117
|
dispatchPath({
|
97
118
|
type: 'added_next_level',
|
@@ -121,7 +142,7 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
121
142
|
});
|
122
143
|
}
|
123
144
|
}
|
124
|
-
if (code ===
|
145
|
+
if (code === keys.Tab || code === keys.Escape) {
|
125
146
|
dispatchFocusedPath({
|
126
147
|
type: 'reset'
|
127
148
|
});
|
@@ -130,7 +151,7 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
130
151
|
});
|
131
152
|
handleGlobalToggle(false, event);
|
132
153
|
}
|
133
|
-
if (code ===
|
154
|
+
if (code === keys.Home) {
|
134
155
|
if (path[0]) {
|
135
156
|
dispatchFocusedPath({
|
136
157
|
type: 'change_last_focus',
|
@@ -146,7 +167,7 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
146
167
|
handleGlobalToggle(true, event);
|
147
168
|
}
|
148
169
|
}
|
149
|
-
if (code ===
|
170
|
+
if (code === keys.End) {
|
150
171
|
if (path[0]) {
|
151
172
|
dispatchFocusedPath({
|
152
173
|
type: 'change_last_focus',
|
@@ -163,23 +184,24 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
163
184
|
handleGlobalToggle(true, event);
|
164
185
|
}
|
165
186
|
}
|
166
|
-
if (code ===
|
187
|
+
if (code === keys.PageUp) {
|
167
188
|
if (path[0]) {
|
168
|
-
if (currentIndex <=
|
189
|
+
if (currentIndex <= JUMP_SIZE) {
|
169
190
|
dispatchFocusedPath({
|
170
|
-
type: '
|
191
|
+
type: 'change_last_focus',
|
192
|
+
value: 0
|
171
193
|
});
|
172
194
|
} else {
|
173
195
|
dispatchFocusedPath({
|
174
196
|
type: 'change_last_focus',
|
175
|
-
value: currentIndex -
|
197
|
+
value: currentIndex - JUMP_SIZE
|
176
198
|
});
|
177
199
|
}
|
178
200
|
}
|
179
201
|
}
|
180
|
-
if (code ===
|
202
|
+
if (code === keys.PageDown) {
|
181
203
|
if (path[0]) {
|
182
|
-
if (currentLength - currentIndex <=
|
204
|
+
if (currentLength - currentIndex <= JUMP_SIZE) {
|
183
205
|
dispatchFocusedPath({
|
184
206
|
type: 'change_last_focus',
|
185
207
|
value: currentLength - 1
|
@@ -187,7 +209,7 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
187
209
|
} else {
|
188
210
|
dispatchFocusedPath({
|
189
211
|
type: 'change_last_focus',
|
190
|
-
value: currentIndex +
|
212
|
+
value: currentIndex + JUMP_SIZE
|
191
213
|
});
|
192
214
|
}
|
193
215
|
}
|