@elliemae/ds-treeview 2.1.0 → 2.2.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/TreeView.js +49 -31
- package/cjs/TreeView.js.map +7 -0
- package/cjs/TreeViewContext.js +53 -35
- package/cjs/TreeViewContext.js.map +7 -0
- package/cjs/config/cssClassesConstants.js +41 -13
- package/cjs/config/cssClassesConstants.js.map +7 -0
- package/cjs/config/useTreeview.js +108 -80
- package/cjs/config/useTreeview.js.map +7 -0
- package/cjs/index.js +37 -27
- package/cjs/index.js.map +7 -0
- package/cjs/parts/CheckboxSelectable.js +70 -59
- package/cjs/parts/CheckboxSelectable.js.map +7 -0
- package/cjs/parts/ChildrenCountDisplayer.js +45 -28
- package/cjs/parts/ChildrenCountDisplayer.js.map +7 -0
- package/cjs/parts/ExpandCaret.js +85 -83
- package/cjs/parts/ExpandCaret.js.map +7 -0
- package/cjs/parts/Icon.js +46 -31
- package/cjs/parts/Icon.js.map +7 -0
- package/cjs/parts/NestingSpace.js +43 -35
- package/cjs/parts/NestingSpace.js.map +7 -0
- package/cjs/parts/RadioSelectable.js +52 -37
- package/cjs/parts/RadioSelectable.js.map +7 -0
- package/cjs/parts/TreeItem.js +128 -147
- package/cjs/parts/TreeItem.js.map +7 -0
- package/cjs/parts/TreeItemText.js +88 -95
- package/cjs/parts/TreeItemText.js.map +7 -0
- package/cjs/parts/TreeList.js +117 -130
- package/cjs/parts/TreeList.js.map +7 -0
- package/cjs/plugins/dnd/TreeDndPlugin.js +51 -36
- package/cjs/plugins/dnd/TreeDndPlugin.js.map +7 -0
- package/cjs/plugins/dnd/index.js +28 -10
- package/cjs/plugins/dnd/index.js.map +7 -0
- package/cjs/plugins/index.js +34 -22
- package/cjs/plugins/index.js.map +7 -0
- package/cjs/plugins/roving/TreeRovingPlugin.js +35 -7
- package/cjs/plugins/roving/TreeRovingPlugin.js.map +7 -0
- package/cjs/plugins/roving/index.js +28 -9
- package/cjs/plugins/roving/index.js.map +7 -0
- package/cjs/plugins/searchable/SearchableTreePlugin.js +35 -7
- package/cjs/plugins/searchable/SearchableTreePlugin.js.map +7 -0
- package/cjs/plugins/searchable/index.js +28 -9
- package/cjs/plugins/searchable/index.js.map +7 -0
- package/cjs/plugins/selectable/SelectablePluginTree.js +35 -7
- package/cjs/plugins/selectable/SelectablePluginTree.js.map +7 -0
- package/cjs/plugins/selectable/index.js +28 -9
- package/cjs/plugins/selectable/index.js.map +7 -0
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js +35 -7
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
- package/cjs/plugins/toolbar/index.js +28 -9
- package/cjs/plugins/toolbar/index.js.map +7 -0
- package/cjs/plugins/tree/TreeDataPlugin.js +35 -7
- package/cjs/plugins/tree/TreeDataPlugin.js.map +7 -0
- package/cjs/plugins/tree/index.js +28 -9
- package/cjs/plugins/tree/index.js.map +7 -0
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +35 -7
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
- package/cjs/plugins/virtualization/index.js +28 -9
- package/cjs/plugins/virtualization/index.js.map +7 -0
- package/cjs/react-desc-prop-types.js +82 -53
- package/cjs/react-desc-prop-types.js.map +7 -0
- package/cjs/related-components/TreeViewSearchBar.js +42 -40
- package/cjs/related-components/TreeViewSearchBar.js.map +7 -0
- package/cjs/sharedTypes.js +27 -2
- package/cjs/sharedTypes.js.map +7 -0
- package/cjs/utils/array-helpers.js +35 -11
- package/cjs/utils/array-helpers.js.map +7 -0
- package/cjs/utils/dnd-helpers.js +90 -84
- package/cjs/utils/dnd-helpers.js.map +7 -0
- package/cjs/utils/group-expands-helpers.js +86 -59
- package/cjs/utils/group-expands-helpers.js.map +7 -0
- package/cjs/utils/keyboard-helpers.js +84 -88
- package/cjs/utils/keyboard-helpers.js.map +7 -0
- package/cjs/utils/object-helpers.js +43 -36
- package/cjs/utils/object-helpers.js.map +7 -0
- package/cjs/utils/refs-helpers.js +43 -22
- package/cjs/utils/refs-helpers.js.map +7 -0
- package/cjs/utils/selectable-helper.js +61 -53
- package/cjs/utils/selectable-helper.js.map +7 -0
- package/cjs/utils/string-helpers.js +35 -7
- package/cjs/utils/string-helpers.js.map +7 -0
- package/cjs/utils/tree-helpers.js +105 -135
- package/cjs/utils/tree-helpers.js.map +7 -0
- package/cjs/utils/useDnDHelpers.js +97 -118
- package/cjs/utils/useDnDHelpers.js.map +7 -0
- package/cjs/utils/useInstanceRefActions.js +54 -43
- package/cjs/utils/useInstanceRefActions.js.map +7 -0
- package/cjs/utils/useTree.js +76 -78
- package/cjs/utils/useTree.js.map +7 -0
- package/esm/TreeView.js +18 -20
- package/esm/TreeView.js.map +7 -0
- package/esm/TreeViewContext.js +24 -29
- package/esm/TreeViewContext.js.map +7 -0
- package/esm/config/cssClassesConstants.js +12 -6
- package/esm/config/cssClassesConstants.js.map +7 -0
- package/esm/config/useTreeview.js +61 -54
- package/esm/config/useTreeview.js.map +7 -0
- package/esm/index.js +8 -9
- package/esm/index.js.map +7 -0
- package/esm/parts/CheckboxSelectable.js +36 -46
- package/esm/parts/CheckboxSelectable.js.map +7 -0
- package/esm/parts/ChildrenCountDisplayer.js +16 -20
- package/esm/parts/ChildrenCountDisplayer.js.map +7 -0
- package/esm/parts/ExpandCaret.js +54 -72
- package/esm/parts/ExpandCaret.js.map +7 -0
- package/esm/parts/Icon.js +16 -22
- package/esm/parts/Icon.js.map +7 -0
- package/esm/parts/NestingSpace.js +14 -27
- package/esm/parts/NestingSpace.js.map +7 -0
- package/esm/parts/RadioSelectable.js +20 -28
- package/esm/parts/RadioSelectable.js.map +7 -0
- package/esm/parts/TreeItem.js +91 -127
- package/esm/parts/TreeItem.js.map +7 -0
- package/esm/parts/TreeItemText.js +58 -85
- package/esm/parts/TreeItemText.js.map +7 -0
- package/esm/parts/TreeList.js +88 -117
- package/esm/parts/TreeList.js.map +7 -0
- package/esm/plugins/dnd/TreeDndPlugin.js +21 -26
- package/esm/plugins/dnd/TreeDndPlugin.js.map +7 -0
- package/esm/plugins/dnd/index.js +3 -1
- package/esm/plugins/dnd/index.js.map +7 -0
- package/esm/plugins/index.js +9 -7
- package/esm/plugins/index.js.map +7 -0
- package/esm/plugins/roving/TreeRovingPlugin.js +6 -3
- package/esm/plugins/roving/TreeRovingPlugin.js.map +7 -0
- package/esm/plugins/roving/index.js +3 -1
- package/esm/plugins/roving/index.js.map +7 -0
- package/esm/plugins/searchable/SearchableTreePlugin.js +6 -3
- package/esm/plugins/searchable/SearchableTreePlugin.js.map +7 -0
- package/esm/plugins/searchable/index.js +3 -1
- package/esm/plugins/searchable/index.js.map +7 -0
- package/esm/plugins/selectable/SelectablePluginTree.js +6 -3
- package/esm/plugins/selectable/SelectablePluginTree.js.map +7 -0
- package/esm/plugins/selectable/index.js +3 -1
- package/esm/plugins/selectable/index.js.map +7 -0
- package/esm/plugins/toolbar/TreeToolbarPlugin.js +6 -3
- package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
- package/esm/plugins/toolbar/index.js +3 -1
- package/esm/plugins/toolbar/index.js.map +7 -0
- package/esm/plugins/tree/TreeDataPlugin.js +6 -3
- package/esm/plugins/tree/TreeDataPlugin.js.map +7 -0
- package/esm/plugins/tree/index.js +3 -1
- package/esm/plugins/tree/index.js.map +7 -0
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +6 -3
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
- package/esm/plugins/virtualization/index.js +3 -1
- package/esm/plugins/virtualization/index.js.map +7 -0
- package/esm/react-desc-prop-types.js +47 -43
- package/esm/react-desc-prop-types.js.map +7 -0
- package/esm/related-components/TreeViewSearchBar.js +13 -32
- package/esm/related-components/TreeViewSearchBar.js.map +7 -0
- package/esm/sharedTypes.js +2 -1
- package/esm/sharedTypes.js.map +7 -0
- package/esm/utils/array-helpers.js +6 -6
- package/esm/utils/array-helpers.js.map +7 -0
- package/esm/utils/dnd-helpers.js +58 -73
- package/esm/utils/dnd-helpers.js.map +7 -0
- package/esm/utils/group-expands-helpers.js +56 -46
- package/esm/utils/group-expands-helpers.js.map +7 -0
- package/esm/utils/keyboard-helpers.js +45 -72
- package/esm/utils/keyboard-helpers.js.map +7 -0
- package/esm/utils/object-helpers.js +14 -31
- package/esm/utils/object-helpers.js.map +7 -0
- package/esm/utils/refs-helpers.js +15 -19
- package/esm/utils/refs-helpers.js.map +7 -0
- package/esm/utils/selectable-helper.js +32 -43
- package/esm/utils/selectable-helper.js.map +7 -0
- package/esm/utils/string-helpers.js +6 -3
- package/esm/utils/string-helpers.js.map +7 -0
- package/esm/utils/tree-helpers.js +74 -119
- package/esm/utils/tree-helpers.js.map +7 -0
- package/esm/utils/useDnDHelpers.js +60 -106
- package/esm/utils/useDnDHelpers.js.map +7 -0
- package/esm/utils/useInstanceRefActions.js +21 -35
- package/esm/utils/useInstanceRefActions.js.map +7 -0
- package/esm/utils/useTree.js +35 -57
- package/esm/utils/useTree.js.map +7 -0
- package/package.json +10 -10
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// 9 tab
|
|
8
|
-
// 13 enter
|
|
9
|
-
// 32 space
|
|
10
|
-
// 37 left arrow
|
|
11
|
-
// 38 up arrow
|
|
12
|
-
// 39 right arrow
|
|
13
|
-
// 40 down arrow
|
|
14
|
-
// 35 end
|
|
15
|
-
// 36 home
|
|
16
|
-
// 56 number 8
|
|
17
|
-
// 106 (NumPad) *
|
|
18
|
-
const useOnItemKeyDown = item => {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useContext, useEffect } from "react";
|
|
3
|
+
import TreeViewContext from "../TreeViewContext";
|
|
4
|
+
import { focusItem } from "./tree-helpers";
|
|
5
|
+
import { toggleExpandAllHelper, toggleItemExpand } from "./group-expands-helpers";
|
|
6
|
+
const useOnItemKeyDown = (item) => {
|
|
19
7
|
const ctx = useContext(TreeViewContext);
|
|
20
8
|
const {
|
|
21
|
-
props: {
|
|
22
|
-
onItemFocus
|
|
23
|
-
},
|
|
9
|
+
props: { onItemFocus },
|
|
24
10
|
triggerTreeRerender,
|
|
25
11
|
isDragging,
|
|
26
12
|
visibleItems,
|
|
@@ -28,63 +14,42 @@ const useOnItemKeyDown = item => {
|
|
|
28
14
|
setSelectedItem,
|
|
29
15
|
setLatestToggledItem,
|
|
30
16
|
updateUserExpandedState,
|
|
31
|
-
virtualListHelpers: {
|
|
32
|
-
scrollToIndex
|
|
33
|
-
}
|
|
17
|
+
virtualListHelpers: { scrollToIndex }
|
|
34
18
|
} = ctx;
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
isExpanded
|
|
38
|
-
} = item;
|
|
39
|
-
const onItemFocusCurry = useCallback(newFocusItem => onItemFocus({
|
|
19
|
+
const { isGroup, isExpanded } = item;
|
|
20
|
+
const onItemFocusCurry = useCallback((newFocusItem) => onItemFocus({
|
|
40
21
|
itemIndex: newFocusItem.virtualIndex,
|
|
41
|
-
scrollToItem:
|
|
42
|
-
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
43
|
-
align: 'start'
|
|
44
|
-
};
|
|
45
|
-
return scrollToIndex(newFocusItem.virtualIndex, opts);
|
|
46
|
-
},
|
|
22
|
+
scrollToItem: (opts = { align: "start" }) => scrollToIndex(newFocusItem.virtualIndex, opts),
|
|
47
23
|
item: newFocusItem
|
|
48
24
|
}), [onItemFocus, scrollToIndex]);
|
|
49
|
-
const onItemKeyDown = useCallback(e => {
|
|
50
|
-
const {
|
|
51
|
-
keyCode
|
|
52
|
-
} = e;
|
|
53
|
-
|
|
25
|
+
const onItemKeyDown = useCallback((e) => {
|
|
26
|
+
const { keyCode } = e;
|
|
54
27
|
if (!isDragging) {
|
|
55
|
-
if (keyCode !== 9)
|
|
56
|
-
|
|
57
|
-
if (keyCode === 13 || keyCode === 32)
|
|
58
|
-
|
|
28
|
+
if (keyCode !== 9)
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
if (keyCode === 13 || keyCode === 32)
|
|
31
|
+
setSelectedItem(item);
|
|
59
32
|
if (keyCode === 37) {
|
|
60
33
|
if (isGroup && isExpanded) {
|
|
61
34
|
toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
|
|
62
35
|
setLatestToggledItem(item);
|
|
63
36
|
}
|
|
64
37
|
}
|
|
65
|
-
|
|
66
38
|
if (keyCode === 39) {
|
|
67
39
|
if (isGroup && !isExpanded) {
|
|
68
40
|
toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
|
|
69
41
|
setLatestToggledItem(item);
|
|
70
42
|
}
|
|
71
43
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
virtualIndex
|
|
75
|
-
} = item;
|
|
76
|
-
|
|
77
|
-
if (typeof virtualIndex === 'number') {
|
|
44
|
+
const { virtualIndex } = item;
|
|
45
|
+
if (typeof virtualIndex === "number") {
|
|
78
46
|
const lastItemIndex = visibleItems.length - 1;
|
|
79
|
-
|
|
80
47
|
if (keyCode === 38) {
|
|
81
48
|
const isLoopedFocus = virtualIndex === 0;
|
|
82
49
|
const newFocusIndex = isLoopedFocus ? lastItemIndex : virtualIndex - 1;
|
|
83
50
|
const newFocusItem = visibleItems[newFocusIndex];
|
|
84
51
|
scrollToIndex(newFocusIndex);
|
|
85
|
-
|
|
86
52
|
if (isLoopedFocus) {
|
|
87
|
-
// when looping the list from start to end we need to wait a bit before focusing
|
|
88
53
|
setTimeout(() => {
|
|
89
54
|
setFocusedItem(newFocusItem);
|
|
90
55
|
focusItem(newFocusItem);
|
|
@@ -96,15 +61,12 @@ const useOnItemKeyDown = item => {
|
|
|
96
61
|
focusItem(newFocusItem);
|
|
97
62
|
}
|
|
98
63
|
}
|
|
99
|
-
|
|
100
64
|
if (keyCode === 40) {
|
|
101
65
|
const isLoopedFocus = virtualIndex === lastItemIndex;
|
|
102
66
|
const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;
|
|
103
67
|
const newFocusItem = visibleItems[newFocusIndex];
|
|
104
68
|
scrollToIndex(newFocusIndex);
|
|
105
|
-
|
|
106
69
|
if (isLoopedFocus) {
|
|
107
|
-
// when looping the list from start to end we need to wait a bit before focusing
|
|
108
70
|
setTimeout(() => {
|
|
109
71
|
setFocusedItem(newFocusItem);
|
|
110
72
|
onItemFocusCurry(newFocusItem);
|
|
@@ -116,7 +78,6 @@ const useOnItemKeyDown = item => {
|
|
|
116
78
|
focusItem(newFocusItem);
|
|
117
79
|
}
|
|
118
80
|
}
|
|
119
|
-
|
|
120
81
|
if (keyCode === 35) {
|
|
121
82
|
if (virtualIndex !== lastItemIndex) {
|
|
122
83
|
const newFocusItem = visibleItems[lastItemIndex];
|
|
@@ -128,7 +89,6 @@ const useOnItemKeyDown = item => {
|
|
|
128
89
|
}, 300);
|
|
129
90
|
}
|
|
130
91
|
}
|
|
131
|
-
|
|
132
92
|
if (keyCode === 36) {
|
|
133
93
|
if (virtualIndex !== 0) {
|
|
134
94
|
const newFocusItem = visibleItems[0];
|
|
@@ -142,27 +102,40 @@ const useOnItemKeyDown = item => {
|
|
|
142
102
|
}
|
|
143
103
|
}
|
|
144
104
|
}
|
|
145
|
-
}, [
|
|
105
|
+
}, [
|
|
106
|
+
isDragging,
|
|
107
|
+
setSelectedItem,
|
|
108
|
+
item,
|
|
109
|
+
isGroup,
|
|
110
|
+
isExpanded,
|
|
111
|
+
triggerTreeRerender,
|
|
112
|
+
scrollToIndex,
|
|
113
|
+
setLatestToggledItem,
|
|
114
|
+
visibleItems,
|
|
115
|
+
setFocusedItem,
|
|
116
|
+
onItemFocusCurry,
|
|
117
|
+
updateUserExpandedState
|
|
118
|
+
]);
|
|
146
119
|
return onItemKeyDown;
|
|
147
120
|
};
|
|
148
|
-
const useGlobalKeyboardListener = func => {
|
|
121
|
+
const useGlobalKeyboardListener = (func) => {
|
|
149
122
|
useEffect(() => {
|
|
150
|
-
document.addEventListener(
|
|
151
|
-
return () => document.removeEventListener(
|
|
123
|
+
document.addEventListener("keydown", func);
|
|
124
|
+
return () => document.removeEventListener("keydown", func);
|
|
152
125
|
}, [func]);
|
|
153
126
|
};
|
|
154
127
|
const useGlobalToggleAllExpandShortcut = (treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
|
|
155
|
-
const memoizedToggleAllKeyboardShortcut = useCallback(e => {
|
|
156
|
-
const {
|
|
157
|
-
shiftKey,
|
|
158
|
-
keyCode
|
|
159
|
-
} = e;
|
|
160
|
-
|
|
128
|
+
const memoizedToggleAllKeyboardShortcut = useCallback((e) => {
|
|
129
|
+
const { shiftKey, keyCode } = e;
|
|
161
130
|
if (shiftKey && keyCode === 56) {
|
|
162
|
-
toggleExpandAllHelper(
|
|
131
|
+
toggleExpandAllHelper("toggle", treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
|
|
163
132
|
}
|
|
164
133
|
}, [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState]);
|
|
165
134
|
return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);
|
|
166
135
|
};
|
|
167
|
-
|
|
168
|
-
|
|
136
|
+
export {
|
|
137
|
+
useGlobalKeyboardListener,
|
|
138
|
+
useGlobalToggleAllExpandShortcut,
|
|
139
|
+
useOnItemKeyDown
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=keyboard-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/keyboard-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\n/* eslint-disable max-lines */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext, useEffect } from 'react';\nimport TreeViewContext from '../TreeViewContext';\nimport { focusItem } from './tree-helpers';\nimport { toggleExpandAllHelper, toggleItemExpand } from './group-expands-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\n\n// 9 tab\n// 13 enter\n// 32 space\n// 37 left arrow\n// 38 up arrow\n// 39 right arrow\n// 40 down arrow\n// 35 end\n// 36 home\n\n// 56 number 8\n// 106 (NumPad) *\n\nexport const useOnItemKeyDown = (item: DSTreeviewT.Item) => {\n const ctx = useContext(TreeViewContext);\n const {\n props: { onItemFocus },\n triggerTreeRerender,\n isDragging,\n visibleItems,\n setFocusedItem,\n setSelectedItem,\n setLatestToggledItem,\n updateUserExpandedState,\n virtualListHelpers: { scrollToIndex },\n } = ctx;\n const { isGroup, isExpanded } = item;\n const onItemFocusCurry = useCallback(\n (newFocusItem: DSTreeviewT.Item) =>\n onItemFocus({\n itemIndex: newFocusItem.virtualIndex as number,\n scrollToItem: (opts = { align: 'start' }) => scrollToIndex(newFocusItem.virtualIndex as number, opts),\n item: newFocusItem,\n }),\n [onItemFocus, scrollToIndex],\n );\n\n const onItemKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLLIElement>) => {\n const { keyCode } = e;\n if (!isDragging) {\n if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab\n if (keyCode === 13 || keyCode === 32) setSelectedItem(item);\n\n if (keyCode === 37) {\n if (isGroup && isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n if (keyCode === 39) {\n if (isGroup && !isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n\n const { virtualIndex } = item;\n if (typeof virtualIndex === 'number') {\n const lastItemIndex = visibleItems.length - 1;\n if (keyCode === 38) {\n const isLoopedFocus = virtualIndex === 0;\n const newFocusIndex = isLoopedFocus ? lastItemIndex : virtualIndex - 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n focusItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 40) {\n const isLoopedFocus = virtualIndex === lastItemIndex;\n const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 35) {\n if (virtualIndex !== lastItemIndex) {\n const newFocusItem = visibleItems[lastItemIndex];\n scrollToIndex(lastItemIndex);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n if (keyCode === 36) {\n if (virtualIndex !== 0) {\n const newFocusItem = visibleItems[0];\n scrollToIndex(0);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n }\n }\n },\n [\n isDragging,\n setSelectedItem,\n item,\n isGroup,\n isExpanded,\n triggerTreeRerender,\n scrollToIndex,\n setLatestToggledItem,\n visibleItems,\n setFocusedItem,\n onItemFocusCurry,\n updateUserExpandedState,\n ],\n );\n\n return onItemKeyDown;\n};\n\nexport const useGlobalKeyboardListener = (func: (e: KeyboardEvent) => void) => {\n useEffect(() => {\n document.addEventListener('keydown', func);\n return () => document.removeEventListener('keydown', func);\n }, [func]);\n};\n\nexport const useGlobalToggleAllExpandShortcut = (\n treeRoot: DSTreeviewT.Item['node'],\n triggerTreeRerender: () => void,\n setLatestToggledItem: DSTreeviewInternalsT.CTX['setLatestToggledItem'],\n updateUserExpandedState: DSTreeviewInternalsT.CTX['updateUserExpandedState'],\n) => {\n const memoizedToggleAllKeyboardShortcut = useCallback(\n (e: KeyboardEvent) => {\n const { shiftKey, keyCode } = e;\n if (shiftKey && keyCode === 56) {\n toggleExpandAllHelper('toggle', treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);\n }\n },\n [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState],\n );\n\n return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,64 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
6
|
-
|
|
7
|
-
/* eslint-disable no-sequences */
|
|
8
|
-
|
|
9
|
-
/* eslint-disable no-return-assign */
|
|
10
|
-
|
|
11
|
-
/* eslint-disable no-restricted-syntax */
|
|
12
|
-
|
|
13
|
-
/* eslint-disable guard-for-in */
|
|
1
|
+
import * as React from "react";
|
|
14
2
|
function isObjectADate(o) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (o === null || o === void 0 ? void 0 : (_o$constructor = o.constructor) === null || _o$constructor === void 0 ? void 0 : _o$constructor.name) === 'Date';
|
|
3
|
+
return o?.constructor?.name === "Date";
|
|
18
4
|
}
|
|
19
|
-
|
|
20
5
|
function isObjectAnArray(o) {
|
|
21
6
|
return Array.isArray(o);
|
|
22
7
|
}
|
|
23
|
-
|
|
24
8
|
function isObjectAString(o) {
|
|
25
|
-
return typeof o ===
|
|
9
|
+
return typeof o === "object";
|
|
26
10
|
}
|
|
27
|
-
|
|
28
|
-
const unfreeze = o => {
|
|
11
|
+
const unfreeze = (o) => {
|
|
29
12
|
let oo;
|
|
30
|
-
|
|
31
13
|
if (o === null) {
|
|
32
14
|
oo = null;
|
|
33
|
-
} else if (o ===
|
|
34
|
-
oo =
|
|
15
|
+
} else if (o === void 0) {
|
|
16
|
+
oo = void 0;
|
|
35
17
|
} else if (isObjectADate(o)) {
|
|
36
18
|
oo = new Date(o);
|
|
37
19
|
} else if (isObjectAnArray(o)) {
|
|
38
20
|
oo = [];
|
|
39
|
-
o.forEach(v => {
|
|
21
|
+
o.forEach((v) => {
|
|
40
22
|
oo.push(v);
|
|
41
23
|
});
|
|
42
24
|
} else if (isObjectAString(o)) {
|
|
43
25
|
oo = String(o);
|
|
44
26
|
} else if (isObjectAString(o)) {
|
|
45
27
|
oo = {};
|
|
46
|
-
|
|
47
28
|
for (const property in o) {
|
|
48
29
|
oo[property] = o[property];
|
|
49
30
|
}
|
|
50
31
|
} else {
|
|
51
32
|
oo = o;
|
|
52
33
|
}
|
|
53
|
-
|
|
54
34
|
return oo;
|
|
55
35
|
};
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
36
|
function filterObject(obj, predicate) {
|
|
58
37
|
return Object.keys(obj).reduce((res, key) => {
|
|
59
|
-
if (predicate(obj[key]))
|
|
38
|
+
if (predicate(obj[key]))
|
|
39
|
+
res[key] = obj[key];
|
|
60
40
|
return res;
|
|
61
41
|
}, {});
|
|
62
42
|
}
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
export {
|
|
44
|
+
filterObject,
|
|
45
|
+
unfreeze
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=object-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/object-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-sequences */\n/* eslint-disable no-return-assign */\n/* eslint-disable no-restricted-syntax */\n/* eslint-disable guard-for-in */\n\nfunction isObjectADate(o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>): o is Date {\n return o?.constructor?.name === 'Date';\n}\nfunction isObjectAnArray(\n o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>,\n): o is unknown[] {\n return Array.isArray(o);\n}\nfunction isObjectAString(\n o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>,\n): o is Record<string, unknown> {\n return typeof o === 'object';\n}\n\nexport const unfreeze = (o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>) => {\n let oo: string | number | unknown[] | Date | null | undefined | Record<string, unknown>;\n if (o === null) {\n oo = null;\n } else if (o === undefined) {\n oo = undefined;\n } else if (isObjectADate(o)) {\n oo = new Date(o);\n } else if (isObjectAnArray(o)) {\n oo = [];\n o.forEach((v) => {\n (oo as unknown[]).push(v);\n });\n } else if (isObjectAString(o)) {\n oo = String(o);\n } else if (isObjectAString(o)) {\n oo = {};\n for (const property in o) {\n oo[property] = o[property];\n }\n } else {\n oo = o;\n }\n return oo;\n};\n\ntype GenericItemT<T = unknown> = { [key: string]: T };\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function filterObject<T = unknown>(obj: GenericItemT<T>, predicate: (val: T) => boolean) {\n return Object.keys(obj).reduce<GenericItemT<T>>((res, key) => {\n if (predicate(obj[key])) res[key] = obj[key];\n return res;\n }, {} as GenericItemT<T>);\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACKA,uBAAuB,GAA+F;AACpH,SAAO,GAAG,aAAa,SAAS;AAAA;AAElC,yBACE,GACgB;AAChB,SAAO,MAAM,QAAQ;AAAA;AAEvB,yBACE,GAC8B;AAC9B,SAAO,OAAO,MAAM;AAAA;AAGf,MAAM,WAAW,CAAC,MAAuF;AAC9G,MAAI;AACJ,MAAI,MAAM,MAAM;AACd,SAAK;AAAA,aACI,MAAM,QAAW;AAC1B,SAAK;AAAA,aACI,cAAc,IAAI;AAC3B,SAAK,IAAI,KAAK;AAAA,aACL,gBAAgB,IAAI;AAC7B,SAAK;AACL,MAAE,QAAQ,CAAC,MAAM;AACf,MAAC,GAAiB,KAAK;AAAA;AAAA,aAEhB,gBAAgB,IAAI;AAC7B,SAAK,OAAO;AAAA,aACH,gBAAgB,IAAI;AAC7B,SAAK;AACL,eAAW,YAAY,GAAG;AACxB,SAAG,YAAY,EAAE;AAAA;AAAA,SAEd;AACL,SAAK;AAAA;AAEP,SAAO;AAAA;AAKF,sBAAmC,KAAsB,WAAgC;AAC9F,SAAO,OAAO,KAAK,KAAK,OAAwB,CAAC,KAAK,QAAQ;AAC5D,QAAI,UAAU,IAAI;AAAO,UAAI,OAAO,IAAI;AACxC,WAAO;AAAA,KACN;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
|
|
7
|
-
// allow multiple refs to be set to point to the same DOM element
|
|
8
|
-
const setMultipleRefs = function () {
|
|
9
|
-
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
|
-
refs[_key] = arguments[_key];
|
|
11
|
-
}
|
|
12
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const setMultipleRefs = (...refs) => {
|
|
13
3
|
const filteredRefs = refs.filter(Boolean);
|
|
14
|
-
if (!filteredRefs.length)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
if (!filteredRefs.length)
|
|
5
|
+
return () => {
|
|
6
|
+
};
|
|
7
|
+
if (filteredRefs.length === 0)
|
|
8
|
+
return () => {
|
|
9
|
+
};
|
|
10
|
+
return (newRef) => {
|
|
11
|
+
filteredRefs.forEach((refToBeUpdated) => {
|
|
12
|
+
if (typeof refToBeUpdated === "function") {
|
|
19
13
|
refToBeUpdated(newRef);
|
|
20
14
|
} else if (refToBeUpdated) {
|
|
21
15
|
refToBeUpdated.current = newRef;
|
|
@@ -23,5 +17,7 @@ const setMultipleRefs = function () {
|
|
|
23
17
|
});
|
|
24
18
|
};
|
|
25
19
|
};
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
export {
|
|
21
|
+
setMultipleRefs
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=refs-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/refs-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// allow multiple refs to be set to point to the same DOM element\ntype GenericMergeableRef = null | undefined | React.MutableRefObject<unknown> | ((ref: HTMLElement) => void);\nexport const setMultipleRefs = (...refs: GenericMergeableRef[]): ((ref: HTMLElement) => void) => {\n const filteredRefs = refs.filter(Boolean);\n if (!filteredRefs.length) return () => {};\n if (filteredRefs.length === 0) return () => {};\n\n return (newRef) => {\n filteredRefs.forEach((refToBeUpdated) => {\n if (typeof refToBeUpdated === 'function') {\n refToBeUpdated(newRef);\n } else if (refToBeUpdated) {\n refToBeUpdated.current = newRef;\n }\n });\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACEO,MAAM,kBAAkB,IAAI,SAA8D;AAC/F,QAAM,eAAe,KAAK,OAAO;AACjC,MAAI,CAAC,aAAa;AAAQ,WAAO,MAAM;AAAA;AACvC,MAAI,aAAa,WAAW;AAAG,WAAO,MAAM;AAAA;AAE5C,SAAO,CAAC,WAAW;AACjB,iBAAa,QAAQ,CAAC,mBAAmB;AACvC,UAAI,OAAO,mBAAmB,YAAY;AACxC,uBAAe;AAAA,iBACN,gBAAgB;AACzB,uBAAe,UAAU;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,70 +1,59 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import { walkAllNodeChildren, walkParents } from './tree-helpers.js';
|
|
8
|
-
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
|
|
11
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
const getGroupCheckState = node => {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { walkParents, walkAllNodeChildren } from "./tree-helpers";
|
|
3
|
+
const getGroupCheckState = (node) => {
|
|
13
4
|
let childAllChecked = true;
|
|
14
5
|
let anyChildChecked = false;
|
|
15
|
-
walkAllNodeChildren(node, childNode => {
|
|
6
|
+
walkAllNodeChildren(node, (childNode) => {
|
|
16
7
|
const {
|
|
17
|
-
model: {
|
|
18
|
-
isChecked
|
|
19
|
-
}
|
|
8
|
+
model: { isChecked }
|
|
20
9
|
} = childNode;
|
|
21
|
-
if (isChecked ===
|
|
10
|
+
if (isChecked === "mixed" || isChecked === true)
|
|
11
|
+
anyChildChecked = true;
|
|
12
|
+
else
|
|
13
|
+
childAllChecked = false;
|
|
22
14
|
});
|
|
23
|
-
if (childAllChecked)
|
|
24
|
-
|
|
15
|
+
if (childAllChecked)
|
|
16
|
+
return true;
|
|
17
|
+
if (anyChildChecked)
|
|
18
|
+
return "mixed";
|
|
25
19
|
return false;
|
|
26
20
|
};
|
|
27
|
-
const selectCheckboxItemModelParentsTillRoot =
|
|
28
|
-
let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
21
|
+
const selectCheckboxItemModelParentsTillRoot = (modelToCheck, triggerTreeRerender = null) => {
|
|
29
22
|
const newSelections = {};
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
} = modelToCheck;
|
|
33
|
-
walkParents(nodePath, parentNode => {
|
|
23
|
+
const { nodePath } = modelToCheck;
|
|
24
|
+
walkParents(nodePath, (parentNode) => {
|
|
34
25
|
const nextState = getGroupCheckState(parentNode);
|
|
35
26
|
parentNode.model.isChecked = nextState;
|
|
36
27
|
newSelections[parentNode.model.id] = nextState;
|
|
37
28
|
});
|
|
38
|
-
if (triggerTreeRerender)
|
|
29
|
+
if (triggerTreeRerender)
|
|
30
|
+
triggerTreeRerender();
|
|
39
31
|
return newSelections;
|
|
40
32
|
};
|
|
41
|
-
const toggleCheckboxItem =
|
|
42
|
-
let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
33
|
+
const toggleCheckboxItem = (itemToSelect, triggerTreeRerender = null) => {
|
|
43
34
|
const {
|
|
44
35
|
node: {
|
|
45
|
-
model: {
|
|
46
|
-
id,
|
|
47
|
-
isChecked,
|
|
48
|
-
children = []
|
|
49
|
-
}
|
|
36
|
+
model: { id, isChecked, children = [] }
|
|
50
37
|
}
|
|
51
38
|
} = itemToSelect;
|
|
52
|
-
const newSelections = {};
|
|
53
|
-
|
|
54
|
-
const nextState = isChecked === 'mixed' ? true : !isChecked;
|
|
39
|
+
const newSelections = {};
|
|
40
|
+
const nextState = isChecked === "mixed" ? true : !isChecked;
|
|
55
41
|
itemToSelect.node.model.isChecked = nextState;
|
|
56
42
|
newSelections[id] = nextState;
|
|
57
|
-
|
|
58
43
|
if (children.length > 0 && (nextState === true || nextState === false)) {
|
|
59
|
-
walkAllNodeChildren(itemToSelect.node, childNode => {
|
|
44
|
+
walkAllNodeChildren(itemToSelect.node, (childNode) => {
|
|
60
45
|
childNode.model.isChecked = nextState;
|
|
61
46
|
newSelections[childNode.model.id] = nextState;
|
|
62
47
|
});
|
|
63
48
|
}
|
|
64
|
-
|
|
65
49
|
const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(itemToSelect);
|
|
66
|
-
if (triggerTreeRerender)
|
|
67
|
-
|
|
50
|
+
if (triggerTreeRerender)
|
|
51
|
+
triggerTreeRerender();
|
|
52
|
+
return { ...parentsNewSelections, ...newSelections };
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
getGroupCheckState,
|
|
56
|
+
selectCheckboxItemModelParentsTillRoot,
|
|
57
|
+
toggleCheckboxItem
|
|
68
58
|
};
|
|
69
|
-
|
|
70
|
-
export { getGroupCheckState, selectCheckboxItemModelParentsTillRoot, toggleCheckboxItem };
|
|
59
|
+
//# sourceMappingURL=selectable-helper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/selectable-helper.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport { walkParents, walkAllNodeChildren } from './tree-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\nexport const getGroupCheckState = (node: DSTreeviewT.Item['node']) => {\n let childAllChecked = true;\n let anyChildChecked = false;\n walkAllNodeChildren(node, (childNode) => {\n const {\n model: { isChecked },\n } = childNode;\n if (isChecked === 'mixed' || isChecked === true) anyChildChecked = true;\n else childAllChecked = false;\n });\n\n if (childAllChecked) return true;\n if (anyChildChecked) return 'mixed';\n return false;\n};\n\nexport const selectCheckboxItemModelParentsTillRoot = (\n modelToCheck: DSTreeviewT.Item,\n triggerTreeRerender: (() => void) | null = null,\n) => {\n const newSelections: DSTreeviewT.SelectionItems = {};\n const { nodePath } = modelToCheck;\n walkParents(nodePath, (parentNode) => {\n const nextState = getGroupCheckState(parentNode);\n parentNode.model.isChecked = nextState;\n newSelections[parentNode.model.id] = nextState;\n });\n if (triggerTreeRerender) triggerTreeRerender();\n return newSelections;\n};\n\nexport const toggleCheckboxItem = (itemToSelect: DSTreeviewT.Item, triggerTreeRerender: (() => void) | null = null) => {\n const {\n node: {\n model: { id, isChecked, children = [] },\n },\n } = itemToSelect;\n\n const newSelections: DSTreeviewT.SelectionItems = {};\n // 'mixed' -> true -> false -> true [...->false -> true]\n const nextState = isChecked === 'mixed' ? true : !isChecked;\n itemToSelect.node.model.isChecked = nextState;\n newSelections[id] = nextState;\n\n if (children.length > 0 && (nextState === true || nextState === false)) {\n walkAllNodeChildren(itemToSelect.node, (childNode) => {\n childNode.model.isChecked = nextState;\n newSelections[childNode.model.id] = nextState;\n });\n }\n\n const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(itemToSelect);\n\n if (triggerTreeRerender) triggerTreeRerender();\n return { ...parentsNewSelections, ...newSelections };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAGO,MAAM,qBAAqB,CAAC,SAAmC;AACpE,MAAI,kBAAkB;AACtB,MAAI,kBAAkB;AACtB,sBAAoB,MAAM,CAAC,cAAc;AACvC,UAAM;AAAA,MACJ,OAAO,EAAE;AAAA,QACP;AACJ,QAAI,cAAc,WAAW,cAAc;AAAM,wBAAkB;AAAA;AAC9D,wBAAkB;AAAA;AAGzB,MAAI;AAAiB,WAAO;AAC5B,MAAI;AAAiB,WAAO;AAC5B,SAAO;AAAA;AAGF,MAAM,yCAAyC,CACpD,cACA,sBAA2C,SACxC;AACH,QAAM,gBAA4C;AAClD,QAAM,EAAE,aAAa;AACrB,cAAY,UAAU,CAAC,eAAe;AACpC,UAAM,YAAY,mBAAmB;AACrC,eAAW,MAAM,YAAY;AAC7B,kBAAc,WAAW,MAAM,MAAM;AAAA;AAEvC,MAAI;AAAqB;AACzB,SAAO;AAAA;AAGF,MAAM,qBAAqB,CAAC,cAAgC,sBAA2C,SAAS;AACrH,QAAM;AAAA,IACJ,MAAM;AAAA,MACJ,OAAO,EAAE,IAAI,WAAW,WAAW;AAAA;AAAA,MAEnC;AAEJ,QAAM,gBAA4C;AAElD,QAAM,YAAY,cAAc,UAAU,OAAO,CAAC;AAClD,eAAa,KAAK,MAAM,YAAY;AACpC,gBAAc,MAAM;AAEpB,MAAI,SAAS,SAAS,KAAM,eAAc,QAAQ,cAAc,QAAQ;AACtE,wBAAoB,aAAa,MAAM,CAAC,cAAc;AACpD,gBAAU,MAAM,YAAY;AAC5B,oBAAc,UAAU,MAAM,MAAM;AAAA;AAAA;AAIxC,QAAM,uBAAuB,uCAAuC;AAEpE,MAAI;AAAqB;AACzB,SAAO,KAAK,yBAAyB;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const standardizeSearchQueryString = (input) => input.trim().toLowerCase();
|
|
3
|
+
export {
|
|
4
|
+
standardizeSearchQueryString
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=string-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/string-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const standardizeSearchQueryString = (input: string) => input.trim().toLowerCase();\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,+BAA+B,CAAC,UAAkB,MAAM,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|