@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.
Files changed (92) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/FactorTypeSelector/FactorTypeSelector.d.ts +2 -2
  3. package/dist/FactorTypeSelector/FactorTypeSelector.js +37 -58
  4. package/dist/FactorTypeSelector/FactorTypeSelector.styles.d.ts +18 -18
  5. package/dist/FactorTypeSelector/FactorTypeSelector.styles.js +10 -10
  6. package/dist/FactorValue/Array/Array.const.js +8 -3
  7. package/dist/FactorValue/Array/Array.d.ts +2 -2
  8. package/dist/FactorValue/Array/Array.js +45 -57
  9. package/dist/FactorValue/Array/Array.styles.d.ts +39 -39
  10. package/dist/FactorValue/Array/Array.styles.js +44 -33
  11. package/dist/FactorValue/Array/Array.types.d.ts +3 -3
  12. package/dist/FactorValue/Array/Array.types.js +1 -1
  13. package/dist/FactorValue/Array/Array.utils.d.ts +2 -2
  14. package/dist/FactorValue/Array/Array.utils.js +21 -18
  15. package/dist/FactorValue/Array/components/ArrayCollector.d.ts +2 -2
  16. package/dist/FactorValue/Array/components/ArrayCollector.js +70 -94
  17. package/dist/FactorValue/Array/components/ArrayCreator.d.ts +2 -2
  18. package/dist/FactorValue/Array/components/ArrayCreator.js +43 -75
  19. package/dist/FactorValue/Array/components/ArrayLimit.d.ts +2 -2
  20. package/dist/FactorValue/Array/components/ArrayLimit.js +16 -14
  21. package/dist/FactorValue/Array/components/ArrayModal.d.ts +2 -2
  22. package/dist/FactorValue/Array/components/ArrayModal.js +78 -143
  23. package/dist/FactorValue/Array/components/ArrayRaw.d.ts +2 -2
  24. package/dist/FactorValue/Array/components/ArrayRaw.js +47 -58
  25. package/dist/FactorValue/Array/components/CopyButton.d.ts +2 -2
  26. package/dist/FactorValue/Array/components/CopyButton.js +20 -30
  27. package/dist/FactorValue/Array/hooks/useCollector.d.ts +3 -3
  28. package/dist/FactorValue/Array/hooks/useCollector.js +21 -22
  29. package/dist/FactorValue/Date/Date.d.ts +2 -2
  30. package/dist/FactorValue/Date/Date.js +38 -53
  31. package/dist/FactorValue/DateRange/DateRange.d.ts +2 -2
  32. package/dist/FactorValue/DateRange/DateRange.js +26 -41
  33. package/dist/FactorValue/DynamicKey/DynamicKey.d.ts +2 -2
  34. package/dist/FactorValue/DynamicKey/DynamicKey.js +37 -66
  35. package/dist/FactorValue/DynamicKey/DynamicKey.style.d.ts +2 -2
  36. package/dist/FactorValue/DynamicKey/DynamicKey.style.js +10 -8
  37. package/dist/FactorValue/FactorValue.d.ts +2 -2
  38. package/dist/FactorValue/FactorValue.js +68 -70
  39. package/dist/FactorValue/FactorValue.style.d.ts +1 -1
  40. package/dist/FactorValue/FactorValue.style.js +20 -20
  41. package/dist/FactorValue/Formula/Formula.d.ts +2 -2
  42. package/dist/FactorValue/Formula/Formula.js +36 -54
  43. package/dist/FactorValue/Formula/Formula.styles.d.ts +1 -1
  44. package/dist/FactorValue/Formula/Formula.styles.js +6 -5
  45. package/dist/FactorValue/Formula/FormulaModal.d.ts +2 -2
  46. package/dist/FactorValue/Formula/FormulaModal.js +27 -42
  47. package/dist/FactorValue/Number/NumberInput.d.ts +2 -2
  48. package/dist/FactorValue/Number/NumberInput.js +21 -31
  49. package/dist/FactorValue/Parameter/Parameter.constants.d.ts +1 -1
  50. package/dist/FactorValue/Parameter/Parameter.constants.js +27 -13
  51. package/dist/FactorValue/Parameter/Parameter.d.ts +2 -2
  52. package/dist/FactorValue/Parameter/Parameter.js +82 -127
  53. package/dist/FactorValue/Parameter/Parameter.style.d.ts +28 -28
  54. package/dist/FactorValue/Parameter/Parameter.style.js +34 -31
  55. package/dist/FactorValue/Parameter/Parameter.types.d.ts +2 -2
  56. package/dist/FactorValue/Parameter/Parameter.types.js +1 -1
  57. package/dist/FactorValue/Parameter/ParameterDropdown.d.ts +2 -2
  58. package/dist/FactorValue/Parameter/ParameterDropdown.js +155 -226
  59. package/dist/FactorValue/Parameter/ParameterDropdownItem.d.ts +3 -3
  60. package/dist/FactorValue/Parameter/ParameterDropdownItem.js +27 -33
  61. package/dist/FactorValue/Parameter/useGroups.d.ts +2 -2
  62. package/dist/FactorValue/Parameter/useGroups.js +30 -42
  63. package/dist/FactorValue/Parameter/utils.d.ts +2 -2
  64. package/dist/FactorValue/Parameter/utils.js +22 -17
  65. package/dist/FactorValue/RelativeDate/RelativeDate.const.d.ts +1 -1
  66. package/dist/FactorValue/RelativeDate/RelativeDate.const.js +12 -5
  67. package/dist/FactorValue/RelativeDate/RelativeDate.d.ts +2 -2
  68. package/dist/FactorValue/RelativeDate/RelativeDate.js +57 -88
  69. package/dist/FactorValue/RelativeDate/RelativeDate.utils.d.ts +1 -1
  70. package/dist/FactorValue/RelativeDate/RelativeDate.utils.js +14 -10
  71. package/dist/FactorValue/RelativeDate/RelativeDateDropdown.d.ts +2 -2
  72. package/dist/FactorValue/RelativeDate/RelativeDateDropdown.js +56 -87
  73. package/dist/FactorValue/RelativeDate/RelativeDateDropdown.styles.d.ts +7 -7
  74. package/dist/FactorValue/RelativeDate/RelativeDateDropdown.styles.js +23 -20
  75. package/dist/FactorValue/Text/Text.d.ts +2 -2
  76. package/dist/FactorValue/Text/Text.js +56 -121
  77. package/dist/FactorValue/Text/Text.styles.d.ts +3 -3
  78. package/dist/FactorValue/Text/Text.styles.js +11 -10
  79. package/dist/FactorValue/Text/TextModal.d.ts +2 -2
  80. package/dist/FactorValue/Text/TextModal.js +19 -33
  81. package/dist/Factors.d.ts +2 -2
  82. package/dist/Factors.js +95 -132
  83. package/dist/Factors.types.d.ts +9 -9
  84. package/dist/Factors.types.js +8 -3
  85. package/dist/hooks/useTexts.d.ts +2 -2
  86. package/dist/hooks/useTexts.js +287 -291
  87. package/dist/index.js +7 -6
  88. package/dist/modules.d.js +1 -1
  89. package/dist/modules.d.ts +0 -0
  90. package/dist/style/Factors.style.d.ts +1 -1
  91. package/dist/style/Factors.style.js +10 -11
  92. package/package.json +32 -32
@@ -1 +1 @@
1
- export {};
1
+
@@ -1,4 +1,4 @@
1
- import React from 'react';
2
- import { type ParameterDropdownProps } from '../../Factors.types';
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
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { v4 as uuid } 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 { focusWithArrowKeys, getClosest, getGroupName, useOnClickOutside, useSearchResults } from '@synerise/ds-utils';
13
- import { DROPDOWN_HEIGHT, ITEM_SIZE, LIST_STYLE, NO_GROUP_NAME, SEARCH_HEGIHT, SUBGROUP_HEADER_HEIGHT, TABS_HEIGHT } from './Parameter.constants';
14
- import * as S from './Parameter.style';
15
- import ParameterDropdownItem from './ParameterDropdownItem';
16
- import { useGroups } from './useGroups';
17
- import { groupItems, isDivider, isListTitle } from './utils';
18
- var ParameterDropdown = function ParameterDropdown(_ref) {
19
- var setSelected = _ref.setSelected,
20
- texts = _ref.texts,
21
- groups = _ref.groups,
22
- items = _ref.items,
23
- recentItems = _ref.recentItems,
24
- setDropdownVisible = _ref.setDropdownVisible,
25
- loading = _ref.loading,
26
- onFetchData = _ref.onFetchData,
27
- hasMoreItems = _ref.hasMoreItems,
28
- _ref$outerHeight = _ref.outerHeight,
29
- outerHeight = _ref$outerHeight === void 0 ? DROPDOWN_HEIGHT : _ref$outerHeight,
30
- value = _ref.value,
31
- _ref$renderEmptyGroup = _ref.renderEmptyGroups,
32
- renderEmptyGroups = _ref$renderEmptyGroup === void 0 ? false : _ref$renderEmptyGroup,
33
- _ref$maxSearchResults = _ref.maxSearchResultsInGroup,
34
- maxSearchResultsInGroup = _ref$maxSearchResults === void 0 ? 4 : _ref$maxSearchResults;
35
- var listRef = useRef(null);
36
- var overlayRef = useRef(null);
37
- var scrollBarRef = useRef(null);
38
- var theme = useTheme();
39
- var _useGroups = useGroups(items, groups, renderEmptyGroups),
40
- visibleGroups = _useGroups.visibleGroups,
41
- tabs = _useGroups.tabs,
42
- defaultTab = _useGroups.defaultTab;
43
- var _useState = useState(''),
44
- searchQuery = _useState[0],
45
- setSearchQuery = _useState[1];
46
- var _useState2 = useState(defaultTab),
47
- activeTab = _useState2[0],
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, function (event) {
59
- if (getClosest(event.target, '.ds-info-card') === null) {
49
+ useOnClickOutside(overlayRef, (event) => {
50
+ if (getClosest(event.target, ".ds-info-card") === null) {
60
51
  setDropdownVisible(false);
61
52
  }
62
53
  });
63
- var currentTabItems = useMemo(function () {
64
- return visibleGroups == null ? void 0 : visibleGroups.find(function (_group, index) {
54
+ const currentTabItems = useMemo(() => {
55
+ return visibleGroups?.find((_group, index) => {
65
56
  return activeTab === index;
66
57
  });
67
58
  }, [visibleGroups, activeTab]);
68
- var resetList = React.useCallback(function () {
59
+ const resetList = React.useCallback(() => {
69
60
  if (listRef.current) {
70
61
  listRef.current.resetAfterIndex(0, false);
71
62
  }
72
63
  }, [listRef]);
73
- var clearSearch = useCallback(function () {
74
- setSearchQuery('');
64
+ const clearSearch = useCallback(() => {
65
+ setSearchQuery("");
75
66
  resetList();
76
67
  }, [setSearchQuery, resetList]);
77
- var handleOnSetGroup = useCallback(function (item) {
68
+ const handleOnSetGroup = useCallback((item) => {
78
69
  setActiveGroup(item);
79
70
  }, []);
80
- var hideDropdown = useCallback(function () {
71
+ const hideDropdown = useCallback(() => {
81
72
  setDropdownVisible(false);
82
73
  resetList();
83
74
  }, [setDropdownVisible, resetList]);
84
- var groupByGroupName = useCallback(function (dropdownItems, maxItemsInGroup) {
85
- var itemsNumber = dropdownItems == null ? void 0 : dropdownItems.length;
86
- var groupedItems = {};
87
- for (var i = 0; i < itemsNumber; i += 1) {
88
- var item = dropdownItems[i];
89
- var groupName = item.groupName || NO_GROUP_NAME;
90
- var group = groupedItems[groupName] || [];
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
- var resultItems = [];
95
- Object.keys(groupedItems).forEach(function (key) {
85
+ const resultItems = [];
86
+ Object.keys(groupedItems).forEach((key) => {
96
87
  if (key !== NO_GROUP_NAME && !activeGroup) {
97
88
  resultItems.push({
98
- type: 'title',
89
+ type: "title",
99
90
  title: key
100
91
  });
101
92
  }
102
- var maxGroupedItems = maxItemsInGroup ? groupedItems[key].slice(0, maxItemsInGroup) : groupedItems[key];
103
- maxGroupedItems.forEach(function (item) {
104
- var resultItem = !item.groupId ? {
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: item,
107
- searchQuery: searchQuery,
97
+ item,
98
+ searchQuery,
108
99
  select: handleOnSetGroup
109
100
  } : {
110
101
  className: classNames,
111
- item: item,
112
- searchQuery: searchQuery,
113
- clearSearch: clearSearch,
114
- hideDropdown: hideDropdown,
102
+ item,
103
+ searchQuery,
104
+ clearSearch,
105
+ hideDropdown,
115
106
  select: setSelected,
116
- selected: value && item.id === (value == null ? void 0 : value.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
- var anyItem = maxGroupedItems[0];
112
+ const anyItem = maxGroupedItems[0];
122
113
  resultItems.push({
123
114
  className: classNames,
124
115
  select: handleOnSetGroup,
125
- searchQuery: searchQuery,
126
- label: /*#__PURE__*/React.createElement(S.ShowMoreItem, null, texts.parameter.showMore),
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: /*#__PURE__*/React.createElement(ArrowRightCircleM, null)
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
- var _useSearchResults = useSearchResults(items || [], groups || [], activeTab, groupByGroupName, activeGroup, searchQuery, maxSearchResultsInGroup),
139
- searchResults = _useSearchResults.searchResults;
140
- var mapItemToDropdownItem = React.useCallback(function (item) {
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: item,
144
- searchQuery: searchQuery,
145
- hideDropdown: hideDropdown,
135
+ item,
136
+ searchQuery,
137
+ hideDropdown,
146
138
  select: setSelected
147
139
  };
148
140
  }, [classNames, searchQuery, hideDropdown, setSelected]);
149
- var currentItems = useMemo(function () {
141
+ const currentItems = useMemo(() => {
150
142
  if (searchQuery) {
151
143
  return searchResults;
152
144
  }
153
- var hasSubgroups = Boolean(currentTabItems == null ? void 0 : currentTabItems.subGroups);
145
+ const hasSubgroups = Boolean(currentTabItems?.subGroups);
154
146
  if (hasSubgroups && !activeGroup) {
155
- var groupedItems = (items || []).filter(function (item) {
156
- return item.groupId === (currentTabItems == null ? void 0 : currentTabItems.id);
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: searchQuery,
163
- select: function select(group) {
152
+ searchQuery,
153
+ select: (group) => {
164
154
  setActiveGroup(group);
165
155
  resetList();
166
156
  }
167
157
  };
168
158
  });
169
- return groupItems([].concat(groupedItems, subGroups), activeGroup);
159
+ return groupItems([...groupedItems, ...subGroups], activeGroup);
170
160
  }
171
161
  if (activeGroup) {
172
- return groupItems((items || []).filter(function (item) {
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 == null ? void 0 : items.filter(function (item) {
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: item,
183
- searchQuery: searchQuery,
184
- hideDropdown: 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(function (item) {
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
- var recentItemsWithGroup = (recentItems || []).map(function (item) {
196
- return _extends({}, item, {
197
- groupName: texts.parameter.recentItemsGroupName
198
- });
199
- });
200
- var itemsWithAllGroup = (items || []).map(function (item) {
201
- return _extends({}, item, {
202
- groupName: texts.parameter.allItemsGroupName
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 == null ? void 0 : items.map(function (item) {
190
+ return items?.map((item) => {
209
191
  return {
210
192
  className: classNames,
211
- item: item,
212
- searchQuery: searchQuery,
213
- hideDropdown: 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
- var handleSearch = useCallback(function (newSearchQuery) {
200
+ const handleSearch = useCallback((newSearchQuery) => {
219
201
  setSearchQuery(newSearchQuery);
220
202
  }, [setSearchQuery]);
221
- var getNoResultContainer = useMemo(function () {
222
- return /*#__PURE__*/React.createElement(Result, {
223
- noSearchResults: true,
224
- type: "no-results",
225
- description: texts.parameter.noResults
226
- });
227
- }, [texts]);
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(function () {
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
- var getItemSize = function getItemSize(index) {
244
- var item = currentItems && currentItems[index];
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
- var hasTabs = tabs.length > 1;
251
- var hasSearch = Boolean(searchQuery);
252
- var dropdownContentHeight = useMemo(function () {
253
- var fixedContentHeight = SEARCH_HEGIHT + (!hasSearch && hasTabs ? TABS_HEIGHT : 0) + (activeGroup ? SUBGROUP_HEADER_HEIGHT : 0);
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 /*#__PURE__*/React.createElement(Dropdown.Wrapper, {
257
- "data-testid": "ds-factors-parameter-dropdown-wrapper",
258
- ref: overlayRef,
259
- onKeyDown: function onKeyDown(event) {
260
- setSearchInputFocus(false);
261
- searchQuery && focusWithArrowKeys(event, classNames.split(' ')[1], function () {
262
- setSearchInputFocus(true);
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(undefined);
244
+ setActiveGroup(void 0);
285
245
  resetList();
286
- }
287
- })), activeGroup && /*#__PURE__*/React.createElement(Dropdown.BackAction, {
288
- label: activeGroup.name,
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
- loading: loading,
304
- hasMore: hasMoreItems,
305
- onYReachEnd: onFetchData,
306
- onScroll: handleScroll,
307
- maxHeight: dropdownContentHeight,
308
- ref: scrollBarRef
309
- }, /*#__PURE__*/React.createElement(ListContextProvider, null, /*#__PURE__*/React.createElement(S.StyledList, {
310
- width: "100%",
311
- height: 300,
312
- itemCount: currentItems.length,
313
- itemSize: getItemSize,
314
- style: LIST_STYLE,
315
- ref: listRef
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 { type ParameterGroup, type ParameterItem } from '../../Factors.types';
3
- import { type DropdownItem } from './Parameter.types';
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
- var _excluded = ["id", "icon"];
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
- import React from 'react';
5
- import Icon from '@synerise/ds-icon';
6
- import ListItem from '@synerise/ds-list-item';
7
- var ParameterDropdownItem = function ParameterDropdownItem(_ref) {
8
- var item = _ref.item,
9
- clearSearch = _ref.clearSearch,
10
- searchQuery = _ref.searchQuery,
11
- hideDropdown = _ref.hideDropdown,
12
- select = _ref.select,
13
- className = _ref.className,
14
- style = _ref.style,
15
- label = _ref.label;
16
- var id = item.id,
17
- icon = item.icon,
18
- itemProps = _objectWithoutPropertiesLoose(item, _excluded);
19
- return /*#__PURE__*/React.createElement(ListItem, _extends({}, itemProps, {
20
- style: style,
21
- className: className,
22
- key: item.name + item.id,
23
- prefixel: /*#__PURE__*/React.createElement(Icon, {
24
- component: icon
25
- }),
26
- highlight: searchQuery,
27
- onClick: function onClick() {
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 { type ParameterGroup, type ParameterItem } from '../../Factors.types';
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("react").ReactNode;
6
+ icon: import('react').ReactNode;
7
7
  }[];
8
8
  defaultTab: number;
9
9
  };