@synerise/ds-factors 1.11.11 → 1.11.13
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/CHANGELOG.md +8 -0
- package/dist/FactorTypeSelector/FactorTypeSelector.d.ts +2 -2
- package/dist/FactorTypeSelector/FactorTypeSelector.js +37 -58
- package/dist/FactorTypeSelector/FactorTypeSelector.styles.d.ts +18 -18
- package/dist/FactorTypeSelector/FactorTypeSelector.styles.js +10 -10
- package/dist/FactorValue/Array/Array.const.js +8 -3
- package/dist/FactorValue/Array/Array.d.ts +2 -2
- package/dist/FactorValue/Array/Array.js +45 -57
- package/dist/FactorValue/Array/Array.styles.d.ts +39 -39
- package/dist/FactorValue/Array/Array.styles.js +44 -33
- package/dist/FactorValue/Array/Array.types.d.ts +3 -3
- package/dist/FactorValue/Array/Array.types.js +1 -1
- package/dist/FactorValue/Array/Array.utils.d.ts +2 -2
- package/dist/FactorValue/Array/Array.utils.js +21 -18
- package/dist/FactorValue/Array/components/ArrayCollector.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayCollector.js +70 -94
- package/dist/FactorValue/Array/components/ArrayCreator.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayCreator.js +43 -75
- package/dist/FactorValue/Array/components/ArrayLimit.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayLimit.js +16 -14
- package/dist/FactorValue/Array/components/ArrayModal.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayModal.js +78 -143
- package/dist/FactorValue/Array/components/ArrayRaw.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayRaw.js +47 -58
- package/dist/FactorValue/Array/components/CopyButton.d.ts +2 -2
- package/dist/FactorValue/Array/components/CopyButton.js +20 -30
- package/dist/FactorValue/Array/hooks/useCollector.d.ts +3 -3
- package/dist/FactorValue/Array/hooks/useCollector.js +21 -22
- package/dist/FactorValue/Date/Date.d.ts +2 -2
- package/dist/FactorValue/Date/Date.js +38 -53
- package/dist/FactorValue/DateRange/DateRange.d.ts +2 -2
- package/dist/FactorValue/DateRange/DateRange.js +26 -41
- package/dist/FactorValue/DynamicKey/DynamicKey.d.ts +2 -2
- package/dist/FactorValue/DynamicKey/DynamicKey.js +37 -66
- package/dist/FactorValue/DynamicKey/DynamicKey.style.d.ts +2 -2
- package/dist/FactorValue/DynamicKey/DynamicKey.style.js +10 -8
- package/dist/FactorValue/FactorValue.d.ts +2 -2
- package/dist/FactorValue/FactorValue.js +68 -70
- package/dist/FactorValue/FactorValue.style.d.ts +1 -1
- package/dist/FactorValue/FactorValue.style.js +20 -20
- package/dist/FactorValue/Formula/Formula.d.ts +2 -2
- package/dist/FactorValue/Formula/Formula.js +36 -54
- package/dist/FactorValue/Formula/Formula.styles.d.ts +1 -1
- package/dist/FactorValue/Formula/Formula.styles.js +6 -5
- package/dist/FactorValue/Formula/FormulaModal.d.ts +2 -2
- package/dist/FactorValue/Formula/FormulaModal.js +27 -42
- package/dist/FactorValue/Number/NumberInput.d.ts +2 -2
- package/dist/FactorValue/Number/NumberInput.js +21 -31
- package/dist/FactorValue/Parameter/Parameter.constants.d.ts +1 -1
- package/dist/FactorValue/Parameter/Parameter.constants.js +27 -13
- package/dist/FactorValue/Parameter/Parameter.d.ts +2 -2
- package/dist/FactorValue/Parameter/Parameter.js +82 -127
- package/dist/FactorValue/Parameter/Parameter.style.d.ts +28 -28
- package/dist/FactorValue/Parameter/Parameter.style.js +34 -31
- package/dist/FactorValue/Parameter/Parameter.types.d.ts +2 -2
- package/dist/FactorValue/Parameter/Parameter.types.js +1 -1
- package/dist/FactorValue/Parameter/ParameterDropdown.d.ts +2 -2
- package/dist/FactorValue/Parameter/ParameterDropdown.js +155 -226
- package/dist/FactorValue/Parameter/ParameterDropdownItem.d.ts +3 -3
- package/dist/FactorValue/Parameter/ParameterDropdownItem.js +27 -33
- package/dist/FactorValue/Parameter/useGroups.d.ts +2 -2
- package/dist/FactorValue/Parameter/useGroups.js +30 -42
- package/dist/FactorValue/Parameter/utils.d.ts +2 -2
- package/dist/FactorValue/Parameter/utils.js +22 -17
- package/dist/FactorValue/RelativeDate/RelativeDate.const.d.ts +1 -1
- package/dist/FactorValue/RelativeDate/RelativeDate.const.js +12 -5
- package/dist/FactorValue/RelativeDate/RelativeDate.d.ts +2 -2
- package/dist/FactorValue/RelativeDate/RelativeDate.js +57 -88
- package/dist/FactorValue/RelativeDate/RelativeDate.utils.d.ts +1 -1
- package/dist/FactorValue/RelativeDate/RelativeDate.utils.js +14 -10
- package/dist/FactorValue/RelativeDate/RelativeDateDropdown.d.ts +2 -2
- package/dist/FactorValue/RelativeDate/RelativeDateDropdown.js +56 -87
- package/dist/FactorValue/RelativeDate/RelativeDateDropdown.styles.d.ts +7 -7
- package/dist/FactorValue/RelativeDate/RelativeDateDropdown.styles.js +23 -20
- package/dist/FactorValue/Text/Text.d.ts +2 -2
- package/dist/FactorValue/Text/Text.js +56 -121
- package/dist/FactorValue/Text/Text.styles.d.ts +3 -3
- package/dist/FactorValue/Text/Text.styles.js +11 -10
- package/dist/FactorValue/Text/TextModal.d.ts +2 -2
- package/dist/FactorValue/Text/TextModal.js +19 -33
- package/dist/Factors.d.ts +2 -2
- package/dist/Factors.js +95 -132
- package/dist/Factors.types.d.ts +9 -9
- package/dist/Factors.types.js +8 -3
- package/dist/hooks/useTexts.d.ts +2 -2
- package/dist/hooks/useTexts.js +287 -291
- package/dist/index.js +7 -6
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/style/Factors.style.d.ts +1 -1
- package/dist/style/Factors.style.js +10 -11
- package/package.json +32 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ParameterDropdownProps } from '../../Factors.types';
|
|
3
3
|
declare const ParameterDropdown: ({ setSelected, texts, groups, items, recentItems, setDropdownVisible, loading, onFetchData, hasMoreItems, outerHeight, value, renderEmptyGroups, maxSearchResultsInGroup, }: ParameterDropdownProps) => React.JSX.Element;
|
|
4
4
|
export default ParameterDropdown;
|
|
@@ -1,238 +1,217 @@
|
|
|
1
|
-
|
|
2
|
-
import React, {
|
|
3
|
-
import { v4
|
|
4
|
-
import { useTheme } from
|
|
5
|
-
import Divider from
|
|
6
|
-
import Dropdown from
|
|
7
|
-
import Icon, { ArrowRightCircleM, SearchM } from
|
|
8
|
-
import { ListContextProvider, itemSizes } from
|
|
9
|
-
import Result from
|
|
10
|
-
import Scrollbar from
|
|
11
|
-
import Tabs from
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import ParameterDropdownItem from
|
|
16
|
-
import { useGroups } from
|
|
17
|
-
import { groupItems, isDivider, isListTitle } from
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
setActiveTab = _useState2[1];
|
|
49
|
-
var _useState3 = useState(undefined),
|
|
50
|
-
activeGroup = _useState3[0],
|
|
51
|
-
setActiveGroup = _useState3[1];
|
|
52
|
-
var _useState4 = useState(true),
|
|
53
|
-
searchInputCanBeFocused = _useState4[0],
|
|
54
|
-
setSearchInputFocus = _useState4[1];
|
|
55
|
-
var classNames = useMemo(function () {
|
|
56
|
-
return "ds-parameter-item ds-parameter-item-" + uuid();
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useRef, useState, useMemo, useCallback, useEffect } from "react";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
import { useTheme } from "@synerise/ds-core";
|
|
5
|
+
import Divider from "@synerise/ds-divider";
|
|
6
|
+
import Dropdown from "@synerise/ds-dropdown";
|
|
7
|
+
import Icon, { ArrowRightCircleM, SearchM } from "@synerise/ds-icon";
|
|
8
|
+
import { ListContextProvider, itemSizes } from "@synerise/ds-list-item";
|
|
9
|
+
import Result from "@synerise/ds-result";
|
|
10
|
+
import Scrollbar from "@synerise/ds-scrollbar";
|
|
11
|
+
import Tabs from "@synerise/ds-tabs";
|
|
12
|
+
import { useOnClickOutside, getClosest, getGroupName, useSearchResults, focusWithArrowKeys } from "@synerise/ds-utils";
|
|
13
|
+
import { NO_GROUP_NAME, DROPDOWN_HEIGHT, LIST_STYLE, SEARCH_HEGIHT, TABS_HEIGHT, SUBGROUP_HEADER_HEIGHT, ITEM_SIZE } from "./Parameter.constants.js";
|
|
14
|
+
import { ShowMoreItem, TabsWrapper, Skeleton, ItemsList, StyledList, Title } from "./Parameter.style.js";
|
|
15
|
+
import ParameterDropdownItem from "./ParameterDropdownItem.js";
|
|
16
|
+
import { useGroups } from "./useGroups.js";
|
|
17
|
+
import { groupItems, isDivider, isListTitle } from "./utils.js";
|
|
18
|
+
const ParameterDropdown = ({
|
|
19
|
+
setSelected,
|
|
20
|
+
texts,
|
|
21
|
+
groups,
|
|
22
|
+
items,
|
|
23
|
+
recentItems,
|
|
24
|
+
setDropdownVisible,
|
|
25
|
+
loading,
|
|
26
|
+
onFetchData,
|
|
27
|
+
hasMoreItems,
|
|
28
|
+
outerHeight = DROPDOWN_HEIGHT,
|
|
29
|
+
value,
|
|
30
|
+
renderEmptyGroups = false,
|
|
31
|
+
maxSearchResultsInGroup = 4
|
|
32
|
+
}) => {
|
|
33
|
+
const listRef = useRef(null);
|
|
34
|
+
const overlayRef = useRef(null);
|
|
35
|
+
const scrollBarRef = useRef(null);
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
const {
|
|
38
|
+
visibleGroups,
|
|
39
|
+
tabs,
|
|
40
|
+
defaultTab
|
|
41
|
+
} = useGroups(items, groups, renderEmptyGroups);
|
|
42
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
43
|
+
const [activeTab, setActiveTab] = useState(defaultTab);
|
|
44
|
+
const [activeGroup, setActiveGroup] = useState(void 0);
|
|
45
|
+
const [searchInputCanBeFocused, setSearchInputFocus] = useState(true);
|
|
46
|
+
const classNames = useMemo(() => {
|
|
47
|
+
return `ds-parameter-item ds-parameter-item-${v4()}`;
|
|
57
48
|
}, []);
|
|
58
|
-
useOnClickOutside(overlayRef,
|
|
59
|
-
if (getClosest(event.target,
|
|
49
|
+
useOnClickOutside(overlayRef, (event) => {
|
|
50
|
+
if (getClosest(event.target, ".ds-info-card") === null) {
|
|
60
51
|
setDropdownVisible(false);
|
|
61
52
|
}
|
|
62
53
|
});
|
|
63
|
-
|
|
64
|
-
return visibleGroups
|
|
54
|
+
const currentTabItems = useMemo(() => {
|
|
55
|
+
return visibleGroups?.find((_group, index) => {
|
|
65
56
|
return activeTab === index;
|
|
66
57
|
});
|
|
67
58
|
}, [visibleGroups, activeTab]);
|
|
68
|
-
|
|
59
|
+
const resetList = React.useCallback(() => {
|
|
69
60
|
if (listRef.current) {
|
|
70
61
|
listRef.current.resetAfterIndex(0, false);
|
|
71
62
|
}
|
|
72
63
|
}, [listRef]);
|
|
73
|
-
|
|
74
|
-
setSearchQuery(
|
|
64
|
+
const clearSearch = useCallback(() => {
|
|
65
|
+
setSearchQuery("");
|
|
75
66
|
resetList();
|
|
76
67
|
}, [setSearchQuery, resetList]);
|
|
77
|
-
|
|
68
|
+
const handleOnSetGroup = useCallback((item) => {
|
|
78
69
|
setActiveGroup(item);
|
|
79
70
|
}, []);
|
|
80
|
-
|
|
71
|
+
const hideDropdown = useCallback(() => {
|
|
81
72
|
setDropdownVisible(false);
|
|
82
73
|
resetList();
|
|
83
74
|
}, [setDropdownVisible, resetList]);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
for (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
const groupByGroupName = useCallback((dropdownItems, maxItemsInGroup) => {
|
|
76
|
+
const itemsNumber = dropdownItems?.length;
|
|
77
|
+
const groupedItems = {};
|
|
78
|
+
for (let i = 0; i < itemsNumber; i += 1) {
|
|
79
|
+
const item = dropdownItems[i];
|
|
80
|
+
const groupName = item.groupName || NO_GROUP_NAME;
|
|
81
|
+
const group = groupedItems[groupName] || [];
|
|
91
82
|
group.push(item);
|
|
92
83
|
groupedItems[groupName] = group;
|
|
93
84
|
}
|
|
94
|
-
|
|
95
|
-
Object.keys(groupedItems).forEach(
|
|
85
|
+
const resultItems = [];
|
|
86
|
+
Object.keys(groupedItems).forEach((key) => {
|
|
96
87
|
if (key !== NO_GROUP_NAME && !activeGroup) {
|
|
97
88
|
resultItems.push({
|
|
98
|
-
type:
|
|
89
|
+
type: "title",
|
|
99
90
|
title: key
|
|
100
91
|
});
|
|
101
92
|
}
|
|
102
|
-
|
|
103
|
-
maxGroupedItems.forEach(
|
|
104
|
-
|
|
93
|
+
const maxGroupedItems = maxItemsInGroup ? groupedItems[key].slice(0, maxItemsInGroup) : groupedItems[key];
|
|
94
|
+
maxGroupedItems.forEach((item) => {
|
|
95
|
+
const resultItem = !item.groupId ? {
|
|
105
96
|
className: classNames,
|
|
106
|
-
item
|
|
107
|
-
searchQuery
|
|
97
|
+
item,
|
|
98
|
+
searchQuery,
|
|
108
99
|
select: handleOnSetGroup
|
|
109
100
|
} : {
|
|
110
101
|
className: classNames,
|
|
111
|
-
item
|
|
112
|
-
searchQuery
|
|
113
|
-
clearSearch
|
|
114
|
-
hideDropdown
|
|
102
|
+
item,
|
|
103
|
+
searchQuery,
|
|
104
|
+
clearSearch,
|
|
105
|
+
hideDropdown,
|
|
115
106
|
select: setSelected,
|
|
116
|
-
selected: value && item.id ===
|
|
107
|
+
selected: value && item.id === value?.id
|
|
117
108
|
};
|
|
118
109
|
resultItems.push(resultItem);
|
|
119
110
|
});
|
|
120
111
|
if (maxItemsInGroup && groupedItems[key].length > maxItemsInGroup) {
|
|
121
|
-
|
|
112
|
+
const anyItem = maxGroupedItems[0];
|
|
122
113
|
resultItems.push({
|
|
123
114
|
className: classNames,
|
|
124
115
|
select: handleOnSetGroup,
|
|
125
|
-
searchQuery
|
|
126
|
-
label:
|
|
116
|
+
searchQuery,
|
|
117
|
+
label: /* @__PURE__ */ jsx(ShowMoreItem, { children: texts.parameter.showMore }),
|
|
127
118
|
item: {
|
|
128
119
|
isGroup: true,
|
|
129
120
|
id: anyItem.groupId,
|
|
130
|
-
name: getGroupName(anyItem.groupId, groups || []) ||
|
|
131
|
-
icon:
|
|
121
|
+
name: getGroupName(anyItem.groupId, groups || []) || "",
|
|
122
|
+
icon: /* @__PURE__ */ jsx(ArrowRightCircleM, {})
|
|
132
123
|
}
|
|
133
124
|
});
|
|
134
125
|
}
|
|
135
126
|
});
|
|
136
127
|
return resultItems;
|
|
137
128
|
}, [activeGroup, classNames, searchQuery, handleOnSetGroup, clearSearch, hideDropdown, setSelected, value, texts.parameter.showMore, groups]);
|
|
138
|
-
|
|
139
|
-
searchResults
|
|
140
|
-
|
|
129
|
+
const {
|
|
130
|
+
searchResults
|
|
131
|
+
} = useSearchResults(items || [], groups || [], activeTab, groupByGroupName, activeGroup, searchQuery, maxSearchResultsInGroup);
|
|
132
|
+
const mapItemToDropdownItem = React.useCallback((item) => {
|
|
141
133
|
return {
|
|
142
134
|
className: classNames,
|
|
143
|
-
item
|
|
144
|
-
searchQuery
|
|
145
|
-
hideDropdown
|
|
135
|
+
item,
|
|
136
|
+
searchQuery,
|
|
137
|
+
hideDropdown,
|
|
146
138
|
select: setSelected
|
|
147
139
|
};
|
|
148
140
|
}, [classNames, searchQuery, hideDropdown, setSelected]);
|
|
149
|
-
|
|
141
|
+
const currentItems = useMemo(() => {
|
|
150
142
|
if (searchQuery) {
|
|
151
143
|
return searchResults;
|
|
152
144
|
}
|
|
153
|
-
|
|
145
|
+
const hasSubgroups = Boolean(currentTabItems?.subGroups);
|
|
154
146
|
if (hasSubgroups && !activeGroup) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}).map(mapItemToDropdownItem);
|
|
158
|
-
var subGroups = ((currentTabItems == null ? void 0 : currentTabItems.subGroups) || []).map(function (subGroup) {
|
|
147
|
+
const groupedItems = (items || []).filter((item) => item.groupId === currentTabItems?.id).map(mapItemToDropdownItem);
|
|
148
|
+
const subGroups = (currentTabItems?.subGroups || []).map((subGroup) => {
|
|
159
149
|
return {
|
|
160
150
|
className: classNames,
|
|
161
151
|
item: subGroup,
|
|
162
|
-
searchQuery
|
|
163
|
-
select:
|
|
152
|
+
searchQuery,
|
|
153
|
+
select: (group) => {
|
|
164
154
|
setActiveGroup(group);
|
|
165
155
|
resetList();
|
|
166
156
|
}
|
|
167
157
|
};
|
|
168
158
|
});
|
|
169
|
-
return groupItems([
|
|
159
|
+
return groupItems([...groupedItems, ...subGroups], activeGroup);
|
|
170
160
|
}
|
|
171
161
|
if (activeGroup) {
|
|
172
|
-
return groupItems((items || []).filter(
|
|
173
|
-
return item.groupId === activeGroup.id;
|
|
174
|
-
}).map(mapItemToDropdownItem), activeGroup);
|
|
162
|
+
return groupItems((items || []).filter((item) => item.groupId === activeGroup.id).map(mapItemToDropdownItem), activeGroup);
|
|
175
163
|
}
|
|
176
164
|
if (activeTab && visibleGroups && visibleGroups[activeTab]) {
|
|
177
|
-
return items
|
|
178
|
-
return item.groupId === visibleGroups[activeTab].id;
|
|
179
|
-
}).map(function (item) {
|
|
165
|
+
return items?.filter((item) => item.groupId === visibleGroups[activeTab].id).map((item) => {
|
|
180
166
|
return {
|
|
181
167
|
className: classNames,
|
|
182
|
-
item
|
|
183
|
-
searchQuery
|
|
184
|
-
hideDropdown
|
|
168
|
+
item,
|
|
169
|
+
searchQuery,
|
|
170
|
+
hideDropdown,
|
|
185
171
|
select: setSelected
|
|
186
172
|
};
|
|
187
173
|
});
|
|
188
174
|
}
|
|
189
175
|
if (activeTab && groups && groups[activeTab]) {
|
|
190
|
-
return groupItems((items || []).filter(
|
|
191
|
-
return item.groupId === groups[activeTab].id;
|
|
192
|
-
}).map(mapItemToDropdownItem), activeGroup);
|
|
176
|
+
return groupItems((items || []).filter((item) => item.groupId === groups[activeTab].id).map(mapItemToDropdownItem), activeGroup);
|
|
193
177
|
}
|
|
194
178
|
if ((recentItems || []).length > 0) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
205
|
-
var result = groupByGroupName(recentItemsWithGroup.concat(itemsWithAllGroup));
|
|
179
|
+
const recentItemsWithGroup = (recentItems || []).map((item) => ({
|
|
180
|
+
...item,
|
|
181
|
+
groupName: texts.parameter.recentItemsGroupName
|
|
182
|
+
}));
|
|
183
|
+
const itemsWithAllGroup = (items || []).map((item) => ({
|
|
184
|
+
...item,
|
|
185
|
+
groupName: texts.parameter.allItemsGroupName
|
|
186
|
+
}));
|
|
187
|
+
const result = groupByGroupName(recentItemsWithGroup.concat(itemsWithAllGroup));
|
|
206
188
|
return result;
|
|
207
189
|
}
|
|
208
|
-
return items
|
|
190
|
+
return items?.map((item) => {
|
|
209
191
|
return {
|
|
210
192
|
className: classNames,
|
|
211
|
-
item
|
|
212
|
-
searchQuery
|
|
213
|
-
hideDropdown
|
|
193
|
+
item,
|
|
194
|
+
searchQuery,
|
|
195
|
+
hideDropdown,
|
|
214
196
|
select: setSelected
|
|
215
197
|
};
|
|
216
198
|
});
|
|
217
199
|
}, [searchQuery, currentTabItems, activeGroup, visibleGroups, items, searchResults, classNames, hideDropdown, setSelected, activeTab, groupByGroupName, recentItems, groups, mapItemToDropdownItem, resetList, texts.parameter.allItemsGroupName, texts.parameter.recentItemsGroupName]);
|
|
218
|
-
|
|
200
|
+
const handleSearch = useCallback((newSearchQuery) => {
|
|
219
201
|
setSearchQuery(newSearchQuery);
|
|
220
202
|
}, [setSearchQuery]);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
var handleScroll = function handleScroll(_ref2) {
|
|
229
|
-
var currentTarget = _ref2.currentTarget;
|
|
230
|
-
var scrollTop = currentTarget.scrollTop;
|
|
203
|
+
const getNoResultContainer = useMemo(() => /* @__PURE__ */ jsx(Result, { noSearchResults: true, type: "no-results", description: texts.parameter.noResults }), [texts]);
|
|
204
|
+
const handleScroll = ({
|
|
205
|
+
currentTarget
|
|
206
|
+
}) => {
|
|
207
|
+
const {
|
|
208
|
+
scrollTop
|
|
209
|
+
} = currentTarget;
|
|
231
210
|
if (listRef.current) {
|
|
232
211
|
listRef.current.scrollTo(scrollTop);
|
|
233
212
|
}
|
|
234
213
|
};
|
|
235
|
-
useEffect(
|
|
214
|
+
useEffect(() => {
|
|
236
215
|
if (scrollBarRef.current && listRef.current) {
|
|
237
216
|
scrollBarRef.current.scrollTo({
|
|
238
217
|
top: 0
|
|
@@ -240,96 +219,46 @@ var ParameterDropdown = function ParameterDropdown(_ref) {
|
|
|
240
219
|
listRef.current.resetAfterIndex(0);
|
|
241
220
|
}
|
|
242
221
|
}, [searchQuery, activeGroup, activeTab]);
|
|
243
|
-
|
|
244
|
-
|
|
222
|
+
const getItemSize = (index) => {
|
|
223
|
+
const item = currentItems && currentItems[index];
|
|
245
224
|
if (isListTitle(item)) {
|
|
246
225
|
return ITEM_SIZE.title;
|
|
247
226
|
}
|
|
248
227
|
return ITEM_SIZE[itemSizes.DEFAULT];
|
|
249
228
|
};
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
229
|
+
const hasTabs = tabs.length > 1;
|
|
230
|
+
const hasSearch = Boolean(searchQuery);
|
|
231
|
+
const dropdownContentHeight = useMemo(() => {
|
|
232
|
+
const fixedContentHeight = SEARCH_HEGIHT + (!hasSearch && hasTabs ? TABS_HEIGHT : 0) + (activeGroup ? SUBGROUP_HEADER_HEIGHT : 0);
|
|
254
233
|
return outerHeight - fixedContentHeight;
|
|
255
234
|
}, [activeGroup, hasSearch, hasTabs, outerHeight]);
|
|
256
|
-
return
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
}, /*#__PURE__*/React.createElement(Dropdown.SearchInput, {
|
|
266
|
-
onSearchChange: handleSearch,
|
|
267
|
-
onClearInput: function onClearInput() {
|
|
268
|
-
return handleSearch('');
|
|
269
|
-
},
|
|
270
|
-
placeholder: texts.parameter.searchPlaceholder,
|
|
271
|
-
value: searchQuery,
|
|
272
|
-
autofocus: !searchQuery || searchInputCanBeFocused,
|
|
273
|
-
autofocusDelay: 50,
|
|
274
|
-
iconLeft: /*#__PURE__*/React.createElement(Icon, {
|
|
275
|
-
component: /*#__PURE__*/React.createElement(SearchM, null),
|
|
276
|
-
color: theme.palette['grey-600']
|
|
277
|
-
})
|
|
278
|
-
}), tabs.length > 1 && /*#__PURE__*/React.createElement(S.TabsWrapper, null, /*#__PURE__*/React.createElement(Tabs, {
|
|
279
|
-
block: true,
|
|
280
|
-
tabs: tabs,
|
|
281
|
-
activeTab: activeTab,
|
|
282
|
-
handleTabClick: function handleTabClick(index) {
|
|
235
|
+
return /* @__PURE__ */ jsxs(Dropdown.Wrapper, { "data-testid": "ds-factors-parameter-dropdown-wrapper", ref: overlayRef, onKeyDown: (event) => {
|
|
236
|
+
setSearchInputFocus(false);
|
|
237
|
+
searchQuery && focusWithArrowKeys(event, classNames.split(" ")[1], () => {
|
|
238
|
+
setSearchInputFocus(true);
|
|
239
|
+
});
|
|
240
|
+
}, children: [
|
|
241
|
+
/* @__PURE__ */ jsx(Dropdown.SearchInput, { onSearchChange: handleSearch, onClearInput: () => handleSearch(""), placeholder: texts.parameter.searchPlaceholder, value: searchQuery, autofocus: !searchQuery || searchInputCanBeFocused, autofocusDelay: 50, iconLeft: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(SearchM, {}), color: theme.palette["grey-600"] }) }),
|
|
242
|
+
tabs.length > 1 && /* @__PURE__ */ jsx(TabsWrapper, { children: /* @__PURE__ */ jsx(Tabs, { block: true, tabs, activeTab, handleTabClick: (index) => {
|
|
283
243
|
setActiveTab(index);
|
|
284
|
-
setActiveGroup(
|
|
244
|
+
setActiveGroup(void 0);
|
|
285
245
|
resetList();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
onClick: function onClick() {
|
|
290
|
-
return setActiveGroup(undefined);
|
|
291
|
-
}
|
|
292
|
-
}), loading ? /*#__PURE__*/React.createElement(S.Skeleton, {
|
|
293
|
-
contentHeight: dropdownContentHeight,
|
|
294
|
-
size: "M",
|
|
295
|
-
numberOfSkeletons: 3
|
|
296
|
-
}) : /*#__PURE__*/React.createElement(S.ItemsList, {
|
|
297
|
-
contentHeight: dropdownContentHeight
|
|
298
|
-
}, currentItems != null && currentItems.length ? /*#__PURE__*/React.createElement(Scrollbar, {
|
|
299
|
-
absolute: true,
|
|
300
|
-
style: {
|
|
246
|
+
} }) }),
|
|
247
|
+
activeGroup && /* @__PURE__ */ jsx(Dropdown.BackAction, { label: activeGroup.name, onClick: () => setActiveGroup(void 0) }),
|
|
248
|
+
loading ? /* @__PURE__ */ jsx(Skeleton, { contentHeight: dropdownContentHeight, size: "M", numberOfSkeletons: 3 }) : /* @__PURE__ */ jsx(ItemsList, { contentHeight: dropdownContentHeight, children: currentItems?.length ? /* @__PURE__ */ jsx(Scrollbar, { absolute: true, style: {
|
|
301
249
|
padding: 8
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}, function (_ref3) {
|
|
317
|
-
var index = _ref3.index,
|
|
318
|
-
style = _ref3.style;
|
|
319
|
-
var listItem = currentItems[index];
|
|
320
|
-
if (listItem && isDivider(listItem)) {
|
|
321
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
322
|
-
style: style
|
|
323
|
-
}, /*#__PURE__*/React.createElement(Divider, {
|
|
324
|
-
marginTop: 8,
|
|
325
|
-
marginBottom: 8
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
return isListTitle(listItem) ? /*#__PURE__*/React.createElement(S.Title, {
|
|
329
|
-
style: style
|
|
330
|
-
}, listItem.title) : /*#__PURE__*/React.createElement(ParameterDropdownItem, _extends({
|
|
331
|
-
style: style
|
|
332
|
-
}, listItem));
|
|
333
|
-
}))) : getNoResultContainer));
|
|
250
|
+
}, loading, hasMore: hasMoreItems, onYReachEnd: onFetchData, onScroll: handleScroll, maxHeight: dropdownContentHeight, ref: scrollBarRef, children: /* @__PURE__ */ jsx(ListContextProvider, { children: /* @__PURE__ */ jsx(StyledList, { width: "100%", height: 300, itemCount: currentItems.length, itemSize: getItemSize, style: LIST_STYLE, ref: listRef, children: ({
|
|
251
|
+
index,
|
|
252
|
+
style
|
|
253
|
+
}) => {
|
|
254
|
+
const listItem = currentItems[index];
|
|
255
|
+
if (listItem && isDivider(listItem)) {
|
|
256
|
+
return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(Divider, { marginTop: 8, marginBottom: 8 }) });
|
|
257
|
+
}
|
|
258
|
+
return isListTitle(listItem) ? /* @__PURE__ */ jsx(Title, { style, children: listItem.title }) : /* @__PURE__ */ jsx(ParameterDropdownItem, { style, ...listItem });
|
|
259
|
+
} }) }) }) : getNoResultContainer })
|
|
260
|
+
] });
|
|
261
|
+
};
|
|
262
|
+
export {
|
|
263
|
+
ParameterDropdown as default
|
|
334
264
|
};
|
|
335
|
-
export default ParameterDropdown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ParameterGroup, ParameterItem } from '../../Factors.types';
|
|
3
|
+
import { DropdownItem } from './Parameter.types';
|
|
4
4
|
declare const ParameterDropdownItem: <ItemType extends ParameterItem | ParameterGroup>({ item, clearSearch, searchQuery, hideDropdown, select, className, style, label, }: DropdownItem<ItemType>) => React.JSX.Element;
|
|
5
5
|
export default ParameterDropdownItem;
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
icon
|
|
18
|
-
itemProps
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
clearSearch && clearSearch();
|
|
29
|
-
hideDropdown && hideDropdown();
|
|
30
|
-
select && select(item);
|
|
31
|
-
}
|
|
32
|
-
}), label || item.name);
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import Icon from "@synerise/ds-icon";
|
|
4
|
+
import ListItem from "@synerise/ds-list-item";
|
|
5
|
+
const ParameterDropdownItem = ({
|
|
6
|
+
item,
|
|
7
|
+
clearSearch,
|
|
8
|
+
searchQuery,
|
|
9
|
+
hideDropdown,
|
|
10
|
+
select,
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
label
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
id,
|
|
17
|
+
icon,
|
|
18
|
+
...itemProps
|
|
19
|
+
} = item;
|
|
20
|
+
return /* @__PURE__ */ createElement(ListItem, { ...itemProps, style, className, key: item.name + item.id, prefixel: /* @__PURE__ */ jsx(Icon, { component: icon }), highlight: searchQuery, onClick: () => {
|
|
21
|
+
clearSearch && clearSearch();
|
|
22
|
+
hideDropdown && hideDropdown();
|
|
23
|
+
select && select(item);
|
|
24
|
+
} }, label || item.name);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
ParameterDropdownItem as default
|
|
33
28
|
};
|
|
34
|
-
export default ParameterDropdownItem;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParameterGroup, ParameterItem } from '../../Factors.types';
|
|
2
2
|
export declare const useGroups: (items?: ParameterItem[], groups?: ParameterGroup[], renderEmptyGroups?: boolean) => {
|
|
3
3
|
visibleGroups: ParameterGroup[] | undefined;
|
|
4
4
|
tabs: {
|
|
5
5
|
label: string;
|
|
6
|
-
icon: import(
|
|
6
|
+
icon: import('react').ReactNode;
|
|
7
7
|
}[];
|
|
8
8
|
defaultTab: number;
|
|
9
9
|
};
|