@laerdal/life-react-components 1.0.1-dev.22.full → 1.0.1-dev.29.full

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 (176) hide show
  1. package/dist/esm/Banners/Banner.js +11 -8
  2. package/dist/esm/Banners/Banner.js.map +1 -1
  3. package/dist/esm/Button/Anchor.js +76 -0
  4. package/dist/esm/Button/Anchor.js.map +1 -0
  5. package/dist/esm/Button/BackButton.js +1 -1
  6. package/dist/esm/Button/BackButton.js.map +1 -1
  7. package/dist/esm/Button/Button.js +46 -19
  8. package/dist/esm/Button/Button.js.map +1 -1
  9. package/dist/esm/Button/DualFunctionButton.js +111 -0
  10. package/dist/esm/Button/DualFunctionButton.js.map +1 -0
  11. package/dist/esm/Button/Iconbutton.js +21 -1
  12. package/dist/esm/Button/Iconbutton.js.map +1 -1
  13. package/dist/esm/Button/__tests__/Button.test.js +2 -1
  14. package/dist/esm/Button/__tests__/Button.test.js.map +1 -1
  15. package/dist/esm/Button/index.js +1 -0
  16. package/dist/esm/Button/index.js.map +1 -1
  17. package/dist/esm/Dropdown/BasicDropdown.js +60 -127
  18. package/dist/esm/Dropdown/BasicDropdown.js.map +1 -1
  19. package/dist/esm/Dropdown/ChipDropdownInput.js +41 -132
  20. package/dist/esm/Dropdown/ChipDropdownInput.js.map +1 -1
  21. package/dist/esm/Dropdown/CommonStyling.js +20 -15
  22. package/dist/esm/Dropdown/CommonStyling.js.map +1 -1
  23. package/dist/esm/Dropdown/DropdownButton.js +2 -2
  24. package/dist/esm/Dropdown/DropdownButton.js.map +1 -1
  25. package/dist/esm/Dropdown/DropdownContent.js +424 -0
  26. package/dist/esm/Dropdown/DropdownContent.js.map +1 -0
  27. package/dist/esm/Dropdown/DropdownFilter.js +42 -151
  28. package/dist/esm/Dropdown/DropdownFilter.js.map +1 -1
  29. package/dist/esm/GlobalNavigationBar/UserMenu/UserMenu.js +15 -17
  30. package/dist/esm/GlobalNavigationBar/UserMenu/UserMenu.js.map +1 -1
  31. package/dist/esm/InputFields/Checkbox.js +19 -10
  32. package/dist/esm/InputFields/Checkbox.js.map +1 -1
  33. package/dist/esm/InputFields/QuickSearch.js +22 -12
  34. package/dist/esm/InputFields/QuickSearch.js.map +1 -1
  35. package/dist/esm/InputFields/RadioButton.js +18 -11
  36. package/dist/esm/InputFields/RadioButton.js.map +1 -1
  37. package/dist/esm/InputFields/components/SearchBarInput.js +1 -1
  38. package/dist/esm/InputFields/components/SearchBarInput.js.map +1 -1
  39. package/dist/esm/Modals/ModalDialog.js +14 -14
  40. package/dist/esm/Modals/ModalDialog.js.map +1 -1
  41. package/dist/esm/Modals/ModalStyles.js +3 -2
  42. package/dist/esm/Modals/ModalStyles.js.map +1 -1
  43. package/dist/esm/Paginator/Paginator.js +18 -8
  44. package/dist/esm/Paginator/Paginator.js.map +1 -1
  45. package/dist/esm/Paginator/__tests__/Paginator.test.js +1 -1
  46. package/dist/esm/Paginator/__tests__/Paginator.test.js.map +1 -1
  47. package/dist/esm/Table/Table.js +2 -1
  48. package/dist/esm/Table/Table.js.map +1 -1
  49. package/dist/esm/Tabs/TabLink.js +1 -1
  50. package/dist/esm/Tabs/TabLink.js.map +1 -1
  51. package/dist/esm/Toasters/Toast.js +2 -1
  52. package/dist/esm/Toasters/Toast.js.map +1 -1
  53. package/dist/esm/types.js +8 -0
  54. package/dist/esm/types.js.map +1 -1
  55. package/dist/js/Banners/Banner.js +13 -11
  56. package/dist/js/Banners/Banner.js.map +1 -1
  57. package/dist/js/Button/Anchor.d.ts +7 -0
  58. package/dist/js/Button/Anchor.js +66 -0
  59. package/dist/js/Button/Anchor.js.map +1 -0
  60. package/dist/js/Button/BackButton.js +1 -1
  61. package/dist/js/Button/BackButton.js.map +1 -1
  62. package/dist/js/Button/Button.d.ts +4 -1
  63. package/dist/js/Button/Button.js +44 -18
  64. package/dist/js/Button/Button.js.map +1 -1
  65. package/dist/js/Button/DualFunctionButton.d.ts +12 -0
  66. package/dist/js/Button/DualFunctionButton.js +148 -0
  67. package/dist/js/Button/DualFunctionButton.js.map +1 -0
  68. package/dist/js/Button/Iconbutton.d.ts +1 -0
  69. package/dist/js/Button/Iconbutton.js +23 -3
  70. package/dist/js/Button/Iconbutton.js.map +1 -1
  71. package/dist/js/Button/__tests__/Button.test.js +3 -1
  72. package/dist/js/Button/__tests__/Button.test.js.map +1 -1
  73. package/dist/js/Button/index.d.ts +1 -0
  74. package/dist/js/Button/index.js +8 -0
  75. package/dist/js/Button/index.js.map +1 -1
  76. package/dist/js/Dropdown/BasicDropdown.d.ts +9 -2
  77. package/dist/js/Dropdown/BasicDropdown.js +67 -133
  78. package/dist/js/Dropdown/BasicDropdown.js.map +1 -1
  79. package/dist/js/Dropdown/ChipDropdownInput.js +45 -138
  80. package/dist/js/Dropdown/ChipDropdownInput.js.map +1 -1
  81. package/dist/js/Dropdown/CommonStyling.d.ts +6 -2
  82. package/dist/js/Dropdown/CommonStyling.js +17 -6
  83. package/dist/js/Dropdown/CommonStyling.js.map +1 -1
  84. package/dist/js/Dropdown/DropdownButton.js +1 -1
  85. package/dist/js/Dropdown/DropdownButton.js.map +1 -1
  86. package/dist/js/Dropdown/DropdownContent.d.ts +45 -0
  87. package/dist/js/Dropdown/DropdownContent.js +476 -0
  88. package/dist/js/Dropdown/DropdownContent.js.map +1 -0
  89. package/dist/js/Dropdown/DropdownFilter.js +59 -186
  90. package/dist/js/Dropdown/DropdownFilter.js.map +1 -1
  91. package/dist/js/GlobalNavigationBar/UserMenu/UserMenu.js +7 -17
  92. package/dist/js/GlobalNavigationBar/UserMenu/UserMenu.js.map +1 -1
  93. package/dist/js/InputFields/Checkbox.d.ts +5 -3
  94. package/dist/js/InputFields/Checkbox.js +16 -9
  95. package/dist/js/InputFields/Checkbox.js.map +1 -1
  96. package/dist/js/InputFields/QuickSearch.js +24 -6
  97. package/dist/js/InputFields/QuickSearch.js.map +1 -1
  98. package/dist/js/InputFields/RadioButton.d.ts +4 -2
  99. package/dist/js/InputFields/RadioButton.js +15 -10
  100. package/dist/js/InputFields/RadioButton.js.map +1 -1
  101. package/dist/js/InputFields/components/SearchBarInput.js +1 -1
  102. package/dist/js/InputFields/components/SearchBarInput.js.map +1 -1
  103. package/dist/js/Modals/ModalDialog.d.ts +2 -1
  104. package/dist/js/Modals/ModalDialog.js +15 -14
  105. package/dist/js/Modals/ModalDialog.js.map +1 -1
  106. package/dist/js/Modals/ModalStyles.d.ts +4 -3
  107. package/dist/js/Modals/ModalStyles.js +4 -2
  108. package/dist/js/Modals/ModalStyles.js.map +1 -1
  109. package/dist/js/Paginator/Paginator.js +7 -5
  110. package/dist/js/Paginator/Paginator.js.map +1 -1
  111. package/dist/js/Paginator/__tests__/Paginator.test.js +1 -1
  112. package/dist/js/Paginator/__tests__/Paginator.test.js.map +1 -1
  113. package/dist/js/Table/Table.js +3 -1
  114. package/dist/js/Table/Table.js.map +1 -1
  115. package/dist/js/Tabs/TabLink.js +1 -1
  116. package/dist/js/Tabs/TabLink.js.map +1 -1
  117. package/dist/js/Toasters/Toast.js +1 -1
  118. package/dist/js/Toasters/Toast.js.map +1 -1
  119. package/dist/js/types.d.ts +5 -0
  120. package/dist/js/types.js +10 -1
  121. package/dist/js/types.js.map +1 -1
  122. package/dist/umd/Banners/Banner.js +11 -8
  123. package/dist/umd/Banners/Banner.js.map +1 -1
  124. package/dist/umd/Button/Anchor.js +201 -0
  125. package/dist/umd/Button/Anchor.js.map +1 -0
  126. package/dist/umd/Button/BackButton.js +1 -1
  127. package/dist/umd/Button/BackButton.js.map +1 -1
  128. package/dist/umd/Button/Button.js +48 -22
  129. package/dist/umd/Button/Button.js.map +1 -1
  130. package/dist/umd/Button/DualFunctionButton.js +237 -0
  131. package/dist/umd/Button/DualFunctionButton.js.map +1 -0
  132. package/dist/umd/Button/Iconbutton.js +21 -1
  133. package/dist/umd/Button/Iconbutton.js.map +1 -1
  134. package/dist/umd/Button/__tests__/Button.test.js +5 -5
  135. package/dist/umd/Button/__tests__/Button.test.js.map +1 -1
  136. package/dist/umd/Button/index.js +10 -4
  137. package/dist/umd/Button/index.js.map +1 -1
  138. package/dist/umd/Dropdown/BasicDropdown.js +64 -131
  139. package/dist/umd/Dropdown/BasicDropdown.js.map +1 -1
  140. package/dist/umd/Dropdown/ChipDropdownInput.js +44 -134
  141. package/dist/umd/Dropdown/ChipDropdownInput.js.map +1 -1
  142. package/dist/umd/Dropdown/CommonStyling.js +23 -19
  143. package/dist/umd/Dropdown/CommonStyling.js.map +1 -1
  144. package/dist/umd/Dropdown/DropdownButton.js +1 -1
  145. package/dist/umd/Dropdown/DropdownButton.js.map +1 -1
  146. package/dist/umd/Dropdown/DropdownContent.js +458 -0
  147. package/dist/umd/Dropdown/DropdownContent.js.map +1 -0
  148. package/dist/umd/Dropdown/DropdownFilter.js +47 -155
  149. package/dist/umd/Dropdown/DropdownFilter.js.map +1 -1
  150. package/dist/umd/GlobalNavigationBar/UserMenu/UserMenu.js +18 -21
  151. package/dist/umd/GlobalNavigationBar/UserMenu/UserMenu.js.map +1 -1
  152. package/dist/umd/InputFields/Checkbox.js +22 -14
  153. package/dist/umd/InputFields/Checkbox.js.map +1 -1
  154. package/dist/umd/InputFields/QuickSearch.js +22 -12
  155. package/dist/umd/InputFields/QuickSearch.js.map +1 -1
  156. package/dist/umd/InputFields/RadioButton.js +21 -15
  157. package/dist/umd/InputFields/RadioButton.js.map +1 -1
  158. package/dist/umd/InputFields/components/SearchBarInput.js +1 -1
  159. package/dist/umd/InputFields/components/SearchBarInput.js.map +1 -1
  160. package/dist/umd/Modals/ModalDialog.js +17 -18
  161. package/dist/umd/Modals/ModalDialog.js.map +1 -1
  162. package/dist/umd/Modals/ModalStyles.js +6 -6
  163. package/dist/umd/Modals/ModalStyles.js.map +1 -1
  164. package/dist/umd/Paginator/Paginator.js +18 -8
  165. package/dist/umd/Paginator/Paginator.js.map +1 -1
  166. package/dist/umd/Paginator/__tests__/Paginator.test.js +1 -1
  167. package/dist/umd/Paginator/__tests__/Paginator.test.js.map +1 -1
  168. package/dist/umd/Table/Table.js +5 -5
  169. package/dist/umd/Table/Table.js.map +1 -1
  170. package/dist/umd/Tabs/TabLink.js +1 -1
  171. package/dist/umd/Tabs/TabLink.js.map +1 -1
  172. package/dist/umd/Toasters/Toast.js +1 -1
  173. package/dist/umd/Toasters/Toast.js.map +1 -1
  174. package/dist/umd/types.js +8 -0
  175. package/dist/umd/types.js.map +1 -1
  176. package/package.json +1 -1
@@ -3,8 +3,10 @@ import * as React from 'react';
3
3
  import { COLORS } from '../styles';
4
4
  import { ArrowDropDown, ArrowDropUp, Information, TechnicalWarning } from '../icons/systemicons/SystemIcons';
5
5
  import { LoadingIndicator } from '../LoadingIndicator';
6
- import { DropdownButton, Dropdown, DropdownContent, StyledField } from './CommonStyling';
6
+ import { Dropdown, StyledField } from './CommonStyling';
7
+ import DropdownContent from './DropdownContent';
7
8
  import { AutofilledMessage, WarningMessage } from '../InputFields/styling';
9
+ import { Size } from '../types';
8
10
  const MAX_MENU_HEIGHT = 240;
9
11
  const AVG_OPTION_HEIGHT = 48;
10
12
 
@@ -16,6 +18,13 @@ const BasicDropdown = ({
16
18
  initalValue,
17
19
  disableSorting,
18
20
  messageOnNoResults,
21
+ itemsType,
22
+ action,
23
+ actionLabel,
24
+ pinTopItem,
25
+ multiSelect,
26
+ scrollable = true,
27
+ maxHeight,
19
28
  disabled,
20
29
  locked,
21
30
  isButton,
@@ -30,9 +39,8 @@ const BasicDropdown = ({
30
39
  const [placeholderSearch, setPlaceholderSearch] = React.useState(placeholder || '');
31
40
  const [restartFilter, setRestartFilter] = React.useState(false);
32
41
  const [focused, setFocused] = React.useState(null);
33
- const [isUp, setIsUp] = React.useState(false);
42
+ const [selectedValues, setSelectedValues] = React.useState([]);
34
43
  const [normalizedList, setNormalizedList] = React.useState([]);
35
- const dropdownContentRef = React.useRef(null);
36
44
  const styledFieldRef = React.useRef(null);
37
45
 
38
46
  const isDropdownItem = item => {
@@ -48,89 +56,32 @@ const BasicDropdown = ({
48
56
  }
49
57
  }
50
58
  }, [list]);
51
-
52
- const handleClickOutside = e => {
53
- if (dropdownContentRef?.current && !dropdownContentRef.current.contains(e.target)) {
54
- if (isOpen) {
55
- setIsOpen(false);
56
- setFocused(null);
57
-
58
- if (!normalizedList.includes(input)) {
59
- setInput('');
60
- setPlaceholderSearch(placeholder || '');
61
- }
62
- }
63
- }
64
- };
65
-
66
- const setNewFocusedElement = index => {
67
- const newFocusedElement = document.getElementById(`${id}_${index}`);
68
-
69
- if (newFocusedElement) {
70
- setFocused(index);
71
- newFocusedElement.focus();
72
- }
73
- };
74
-
75
- const handleKeyDown = e => {
76
- if (isOpen) {
77
- if (e.keyCode === 38) {
78
- e.preventDefault();
79
- var focusedNow = focused;
80
-
81
- if (focusedNow !== undefined && focusedNow !== null && focusedNow > 0) {
82
- focusedNow -= 1;
83
- setNewFocusedElement(focusedNow);
84
- }
85
- } else if (e.keyCode === 40) {
86
- e.preventDefault();
87
- var focusedNow = focused;
88
-
89
- if (focusedNow !== undefined && focusedNow !== null) {
90
- focusedNow++;
91
- } else {
92
- focusedNow = 0;
93
- }
94
-
95
- setNewFocusedElement(focusedNow);
96
- } else if (e.keyCode === 9) {
97
- e.preventDefault();
98
- var focusedNow = focused;
99
-
100
- if (focusedNow !== undefined && focusedNow !== null) {
101
- focusedNow++;
102
- const newFocusedElement = document.getElementById(`${id}_${focusedNow}`);
103
-
104
- if (!newFocusedElement) {
105
- setNewFocusedElement(0);
106
- } else {
107
- setNewFocusedElement(focusedNow);
108
- }
109
- } else {
110
- setNewFocusedElement(0);
111
- }
112
- } else if (e.keyCode === 27) {
113
- setIsOpen(false);
114
- setNewFocusedElement(0);
115
- }
116
- }
117
- };
59
+ /*
60
+ if (!items.includes(input)) {
61
+ setInput('');
62
+ setPlaceholderSearch(placeholder || '');
63
+ } */
118
64
 
119
65
  const handleKeyPress = e => {
120
66
  if (styledFieldRef?.current && styledFieldRef.current.contains(e.target)) {
121
67
  if (e.keyCode === 13) {
122
68
  setIsOpen(!isOpen);
123
- setNewFocusedElement(0);
124
69
  } else if (e.keyCode === 40) {
125
70
  setIsOpen(!isOpen);
126
- setNewFocusedElement(0);
127
71
  }
128
72
  }
129
73
  };
130
74
 
131
- React.useEffect(() => {
132
- determineDropUp();
133
- }, [isOpen]);
75
+ const handleValueSelect = values => {
76
+ setRestartFilter(true);
77
+ setInput(values.join(', '));
78
+ onSelect && onSelect(values); //don't close dropdown on item select if have custom action or multiselect
79
+
80
+ if (actionLabel || multiSelect) return;
81
+ setIsOpen(false);
82
+ setFocused(null);
83
+ };
84
+
134
85
  React.useEffect(() => {
135
86
  if (initalValue) {
136
87
  setInput(initalValue);
@@ -138,63 +89,18 @@ const BasicDropdown = ({
138
89
  }
139
90
  }, [initalValue]);
140
91
  React.useEffect(() => {
141
- document.addEventListener('keydown', handleKeyDown);
142
92
  document.addEventListener('keypress', handleKeyPress);
143
- document.addEventListener('click', handleClickOutside);
144
93
  return () => {
145
- document.removeEventListener('keydown', handleKeyDown);
146
94
  document.removeEventListener('keypress', handleKeyPress);
147
- document.removeEventListener('click', handleClickOutside);
148
95
  };
149
96
  });
150
97
  React.useEffect(() => {
151
98
  setIsLoading(false);
152
99
  }, [input]);
153
100
 
154
- const getElements = () => {
155
- var number = 0;
156
- var options = normalizedList;
157
-
158
- if (!restartFilter && input !== '') {
159
- options = options.filter(option => option.toUpperCase().indexOf(input.toUpperCase()) !== -1);
160
- }
161
-
162
- if (!disableSorting) {
163
- options = options.sort();
164
- }
165
-
166
- if (options.length === 0) {
167
- return /*#__PURE__*/React.createElement(DropdownButton, {
168
- disabled: true
169
- }, /*#__PURE__*/React.createElement("span", null, messageOnNoResults));
170
- }
171
-
172
- return options.map(item => {
173
- return /*#__PURE__*/React.createElement(DropdownButton, {
174
- type: "button",
175
- onClick: e => {
176
- e.preventDefault();
177
- setRestartFilter(true);
178
- setInput(item);
179
- onSelect && onSelect(item);
180
- setIsOpen(false);
181
- setFocused(null);
182
- },
183
- className: item === input ? 'active' : '',
184
- key: item,
185
- id: `${id}_${number++}`
186
- }, /*#__PURE__*/React.createElement("span", null, item));
187
- });
188
- };
189
-
190
- const determineDropUp = () => {
191
- const options = normalizedList;
192
- const node = dropdownContentRef.current;
193
- if (!node) return;
194
- const windowHeight = window.innerHeight;
195
- const menuHeight = Math.min(MAX_MENU_HEIGHT, options.length * AVG_OPTION_HEIGHT);
196
- const instOffsetWithMenu = node.getBoundingClientRect().top + menuHeight;
197
- setIsUp(instOffsetWithMenu >= windowHeight);
101
+ const customSetIsOpen = isOpen => {
102
+ console.log('dropdown content triggered');
103
+ setIsOpen(isOpen);
198
104
  };
199
105
 
200
106
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Dropdown, {
@@ -231,11 +137,31 @@ const BasicDropdown = ({
231
137
  size: "24px",
232
138
  className: size ? size : ''
233
139
  }))), !locked && !disabled && /*#__PURE__*/React.createElement(DropdownContent, {
140
+ customizationProps: {
141
+ itemsType: itemsType,
142
+ action: action ?? (() => {}),
143
+ actionLabel: actionLabel,
144
+ scrollable: scrollable,
145
+ isButton: isButton || false,
146
+ onValueUpdate: handleValueSelect,
147
+ items: normalizedList.map(x => ({
148
+ value: x
149
+ })),
150
+ multiSelect: multiSelect,
151
+ pinTopItem: pinTopItem,
152
+ maxHeight: maxHeight
153
+ },
154
+ size: size == 'medium' ? Size.Medium : Size.Small,
155
+ filter: '',
156
+ hideOnClickOutside: true,
157
+ isOpen: isOpen,
158
+ setIsOpen: customSetIsOpen,
159
+ messageOnNoResults: messageOnNoResults ?? '',
234
160
  isButton: isButton || false,
235
- ref: dropdownContentRef,
236
- id: `${id}_dropdowncontent`,
237
- className: [isOpen && 'show', isUp && 'up'].filter(e => !!e).join(' ')
238
- }, getElements())), activeValidationMessage && /*#__PURE__*/React.createElement(WarningMessage, null, /*#__PURE__*/React.createElement(TechnicalWarning, {
161
+ selectedValues: selectedValues,
162
+ setSelectedValues: setSelectedValues,
163
+ id: `${id}_dropdowncontent`
164
+ })), activeValidationMessage && /*#__PURE__*/React.createElement(WarningMessage, null, /*#__PURE__*/React.createElement(TechnicalWarning, {
239
165
  size: "20px",
240
166
  color: COLORS.warning_400
241
167
  }), /*#__PURE__*/React.createElement("span", null, activeValidationMessage)), autofilledMessage && /*#__PURE__*/React.createElement(AutofilledMessage, null, /*#__PURE__*/React.createElement(Information, {
@@ -247,6 +173,13 @@ const BasicDropdown = ({
247
173
  BasicDropdown.propTypes = {
248
174
  id: _pt.string.isRequired,
249
175
  list: _pt.oneOfType([_pt.arrayOf(_pt.string), _pt.array]).isRequired,
176
+ itemsType: _pt.oneOf(['normal', 'checkbox', 'radio']).isRequired,
177
+ action: _pt.func,
178
+ actionLabel: _pt.string,
179
+ pinTopItem: _pt.bool,
180
+ multiSelect: _pt.bool,
181
+ scrollable: _pt.bool,
182
+ maxHeight: _pt.string,
250
183
  placeholder: _pt.string,
251
184
  onSelect: _pt.func,
252
185
  initalValue: _pt.string,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Dropdown/BasicDropdown.tsx"],"names":["React","COLORS","ArrowDropDown","ArrowDropUp","Information","TechnicalWarning","LoadingIndicator","DropdownButton","Dropdown","DropdownContent","StyledField","AutofilledMessage","WarningMessage","MAX_MENU_HEIGHT","AVG_OPTION_HEIGHT","BasicDropdown","id","list","placeholder","onSelect","initalValue","disableSorting","messageOnNoResults","disabled","locked","isButton","activeValidationMessage","autofilledMessage","size","margin","isOpen","setIsOpen","useState","isLoading","setIsLoading","input","setInput","placeholderSearch","setPlaceholderSearch","restartFilter","setRestartFilter","focused","setFocused","isUp","setIsUp","normalizedList","setNormalizedList","dropdownContentRef","useRef","styledFieldRef","isDropdownItem","item","label","undefined","useEffect","length","map","i","handleClickOutside","e","current","contains","target","includes","setNewFocusedElement","index","newFocusedElement","document","getElementById","focus","handleKeyDown","keyCode","preventDefault","focusedNow","handleKeyPress","determineDropUp","addEventListener","removeEventListener","getElements","number","options","filter","option","toUpperCase","indexOf","sort","node","windowHeight","window","innerHeight","menuHeight","Math","min","instOffsetWithMenu","getBoundingClientRect","top","concat","neutral_600","join","warning_400"],"mappings":";AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,SAASC,aAAT,EAAwBC,WAAxB,EAAqCC,WAArC,EAAkDC,gBAAlD,QAA0E,kCAA1E;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AACA,SAASC,cAAT,EAAyBC,QAAzB,EAAmCC,eAAnC,EAAoDC,WAApD,QAAuE,iBAAvE;AACA,SAASC,iBAAT,EAA4BC,cAA5B,QAAkD,wBAAlD;AAoBA,MAAMC,eAAe,GAAG,GAAxB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;AAEA,MAAMC,aAAa,GAAG,CAAC;AACrBC,EAAAA,EADqB;AAErBC,EAAAA,IAFqB;AAGrBC,EAAAA,WAHqB;AAIrBC,EAAAA,QAJqB;AAKrBC,EAAAA,WALqB;AAMrBC,EAAAA,cANqB;AAOrBC,EAAAA,kBAPqB;AAQrBC,EAAAA,QARqB;AASrBC,EAAAA,MATqB;AAUrBC,EAAAA,QAVqB;AAWrBC,EAAAA,uBAXqB;AAYrBC,EAAAA,iBAZqB;AAarBC,EAAAA,IAbqB;AAcrBC,EAAAA,MAAM,GAAG;AAdY,CAAD,KAeK;AACzB,QAAM,CAACC,MAAD,EAASC,SAAT,IAAsB/B,KAAK,CAACgC,QAAN,CAAwB,KAAxB,CAA5B;AACA,QAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4BlC,KAAK,CAACgC,QAAN,CAAwB,KAAxB,CAAlC;AACA,QAAM,CAACG,KAAD,EAAQC,QAAR,IAAoBpC,KAAK,CAACgC,QAAN,CAAuB,EAAvB,CAA1B;AACA,QAAM,CAACK,iBAAD,EAAoBC,oBAApB,IAA4CtC,KAAK,CAACgC,QAAN,CAAuBd,WAAW,IAAI,EAAtC,CAAlD;AACA,QAAM,CAACqB,aAAD,EAAgBC,gB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port { ArrowDropDown, ArrowDropUp, Information, TechnicalWarning } from '../icons/systemicons/SystemIcons';\nimport { LoadingIndicator } from '../LoadingIndicator';\nimport { DropdownButton, Dropdown, DropdownContent, StyledField } from './CommonStyling';\nimport { AutofilledMessage, WarningMessage } from '../InputFields/styling';\nimport { DropdownItem } from './DropdownButtonTypes';\n\ninterface DropdownFilterProps {\n id: string;\n list: string[] | DropdownItem[];\n placeholder?: string;\n onSelect?: (value: string) => void;\n initalValue?: string;\n disableSorting?: boolean;\n messageOnNoResults?: string;\n disabled?: boolean;\n locked?: boolean;\n isButton?: boolean;\n activeValidationMessage?: string;\n autofilledMessage?: string;\n size?: 'small' | 'medium';\n margin?: string;\n}\n\nconst MAX_MENU_HEIGHT = 240;\nconst AVG_OPTION_HEIGHT = 48;\n\nconst BasicDropdown = ({\n id,\n list,\n placeholder,\n onSelect,\n initalValue,\n disableSorting,\n messageOnNoResults,\n disabled,\n locked,\n isButton,\n activeValidationMessage,\n autofilledMessage,\n size,\n margin = '4px 0',\n}: DropdownFilterProps) => {\n const [isOpen, setIsOpen] = React.useState<Boolean>(false);\n const [isLoading, setIsLoading] = React.useState<Boolean>(false);\n const [input, setInput] = React.useState<string>('');\n const [placeholderSearch, setPlaceholderSearch] = React.useState<string>(placeholder || '');\n const [restartFilter, setRestartFilter] = React.useState<boolean>(false);\n const [focused, setFocused] = React.useState<number | null>(null);\n const [isUp, setIsUp] = React.useState<boolean>(false);\n const [normalizedList, setNormalizedList] = React.useState<string[]>([]);\n const dropdownContentRef = React.useRef<HTMLDivElement>(null);\n const styledFieldRef = React.useRef<HTMLDivElement>(null);\n\n const isDropdownItem = (item: string | DropdownItem) => {\n return (item as DropdownItem).label !== undefined;\n };\n\n React.useEffect(() => {\n if (list.length > 0) {\n if (isDropdownItem(list[0])) {\n setNormalizedList((list as (string | DropdownItem)[]).map((i: string | DropdownItem) => (i as DropdownItem).label));\n } else {\n setNormalizedList((list as (string | DropdownItem)[]).map((i: string | DropdownItem) => i as string));\n }\n }\n }, [list]);\n\n const handleClickOutside = (e: any) => {\n if (dropdownContentRef?.current && !dropdownContentRef.current.contains(e.target)) {\n if (isOpen) {\n setIsOpen(false);\n setFocused(null);\n if (!normalizedList.includes(input)) {\n setInput('');\n setPlaceholderSearch(placeholder || '');\n }\n }\n }\n };\n\n const setNewFocusedElement = (index: number) => {\n const newFocusedElement = document.getElementById(`${id}_${index}`);\n if (newFocusedElement) {\n setFocused(index);\n newFocusedElement.focus();\n }\n };\n\n const handleKeyDown = (e: any) => {\n if (isOpen) {\n if (e.keyCode === 38) {\n e.preventDefault();\n var focusedNow = focused;\n if (focusedNow !== undefined && focusedNow !== null && focusedNow > 0) {\n focusedNow -= 1;\n setNewFocusedElement(focusedNow);\n }\n } else if (e.keyCode === 40) {\n e.preventDefault();\n var focusedNow = focused;\n if (focusedNow !== undefined && focusedNow !== null) {\n focusedNow++;\n } else {\n focusedNow = 0;\n }\n setNewFocusedElement(focusedNow);\n } else if (e.keyCode === 9) {\n e.preventDefault();\n var focusedNow = focused;\n if (focusedNow !== undefined && focusedNow !== null) {\n focusedNow++;\n const newFocusedElement = document.getElementById(`${id}_${focusedNow}`);\n if (!newFocusedElement) {\n setNewFocusedElement(0);\n } else {\n setNewFocusedElement(focusedNow);\n }\n } else {\n setNewFocusedElement(0);\n }\n } else if (e.keyCode === 27) {\n setIsOpen(false);\n setNewFocusedElement(0);\n }\n }\n };\n\n const handleKeyPress = (e: any) => {\n if (styledFieldRef?.current && styledFieldRef.current.contains(e.target)) {\n if (e.keyCode === 13) {\n setIsOpen(!isOpen);\n setNewFocusedElement(0);\n } else if (e.keyCode === 40) {\n setIsOpen(!isOpen);\n setNewFocusedElement(0);\n }\n }\n };\n\n React.useEffect(() => {\n determineDropUp();\n }, [isOpen]);\n\n React.useEffect(() => {\n if (initalValue) {\n setInput(initalValue);\n setRestartFilter(true);\n }\n }, [initalValue]);\n\n React.useEffect(() => {\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keypress', handleKeyPress);\n document.addEventListener('click', handleClickOutside);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keypress', handleKeyPress);\n document.removeEventListener('click', handleClickOutside);\n };\n });\n\n React.useEffect(() => {\n setIsLoading(false);\n }, [input]);\n\n const getElements = () => {\n var number = 0;\n var options = normalizedList;\n if (!restartFilter && input !== '') {\n options = options.filter((option) => option.toUpperCase().indexOf(input.toUpperCase()) !== -1);\n }\n if (!disableSorting) {\n options = options.sort();\n }\n if (options.length === 0) {\n return (\n <DropdownButton disabled>\n <span>{messageOnNoResults}</span>\n </DropdownButton>\n );\n }\n return options.map((item) => {\n return (\n <DropdownButton\n type=\"button\"\n onClick={(e: any) => {\n e.preventDefault();\n setRestartFilter(true);\n setInput(item);\n onSelect && onSelect(item);\n setIsOpen(false);\n setFocused(null);\n }}\n className={item === input ? 'active' : ''}\n key={item}\n id={`${id}_${number++}`}>\n <span>{item}</span>\n </DropdownButton>\n );\n });\n };\n\n const determineDropUp = () => {\n const options = normalizedList;\n const node = dropdownContentRef.current;\n\n if (!node) return;\n\n const windowHeight = window.innerHeight;\n const menuHeight = Math.min(MAX_MENU_HEIGHT, options.length * AVG_OPTION_HEIGHT);\n const instOffsetWithMenu = node.getBoundingClientRect().top + menuHeight;\n setIsUp(instOffsetWithMenu >= windowHeight);\n };\n\n return (\n <>\n <Dropdown isButton={isButton || false} className={size ? size : ''} locked={locked} disabled={disabled} margin={margin}>\n <StyledField\n ref={styledFieldRef}\n className={(isOpen ? 'expanded ' : '').concat(size ? size : '').concat(isButton ? 'button' : '')}\n onClick={() => {\n if (!locked || !disabled) {\n setIsOpen(!isOpen);\n }\n }}\n tabIndex={disabled || locked ? -1 : 0}\n disabled={disabled || false}\n locked={locked || false}\n showValidationMessage={!!activeValidationMessage}\n isPlaceholder={!input}>\n <div className={'value'}>{input || placeholderSearch}</div>\n {isLoading ? <LoadingIndicator size=\"small\" color={COLORS.neutral_600} /> : null}\n <div onClick={() => setIsOpen(!isOpen)} className={'icon'}>\n {isOpen ? <ArrowDropUp size=\"24px\" className={size ? size : ''} /> : <ArrowDropDown size=\"24px\" className={size ? size : ''} />}\n </div>\n </StyledField>\n {!locked && !disabled && (\n <DropdownContent\n isButton={isButton || false}\n ref={dropdownContentRef}\n id={`${id}_dropdowncontent`}\n className={[isOpen && 'show', isUp && 'up'].filter((e) => !!e).join(' ')}>\n {getElements()}\n </DropdownContent>\n )}\n </Dropdown>\n {activeValidationMessage && (\n <WarningMessage>\n <TechnicalWarning size=\"20px\" color={COLORS.warning_400} />\n <span>{activeValidationMessage}</span>\n </WarningMessage>\n )}\n {autofilledMessage && (\n <AutofilledMessage>\n <Information size=\"20px\" color={COLORS.neutral_600} />\n <span>{autofilledMessage}</span>\n </AutofilledMessage>\n )}\n </>\n );\n};\n\nexport default BasicDropdown;\n"],"file":"BasicDropdown.js"}
1
+ {"version":3,"sources":["../../../src/Dropdown/BasicDropdown.tsx"],"names":["React","COLORS","ArrowDropDown","ArrowDropUp","Information","TechnicalWarning","LoadingIndicator","Dropdown","StyledField","DropdownContent","AutofilledMessage","WarningMessage","Size","MAX_MENU_HEIGHT","AVG_OPTION_HEIGHT","BasicDropdown","id","list","placeholder","onSelect","initalValue","disableSorting","messageOnNoResults","itemsType","action","actionLabel","pinTopItem","multiSelect","scrollable","maxHeight","disabled","locked","isButton","activeValidationMessage","autofilledMessage","size","margin","isOpen","setIsOpen","useState","isLoading","setIsLoading","input","setInput","placeholderSearch","setPlaceholderSearch","restartFilter","setRestartFilter","focused","setFocused","selectedValues","setSelectedValues","normalizedList","setNormalizedList","styledFieldRef","useRef","isDropdownItem","item","label","undefined","useEffect","length","map","i","handleKeyPress","e","current","contains","target","keyCode","handleValueSelect","values","join","document","addEventListener","removeEventListener","customSetIsOpen","console","log","concat","neutral_600","onValueUpdate","items","x","value","Medium","Small","warning_400"],"mappings":";AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,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ADF,EAgDGiB,uBAAuB,iBACtB,oBAAC,cAAD,qBACE,oBAAC,gBAAD;AAAkB,IAAA,IAAI,EAAC,MAAvB;AAA8B,IAAA,KAAK,EAAEhC,MAAM,CAACsF;AAA5C,IADF,eAEE,kCAAOtD,uBAAP,CAFF,CAjDJ,EAsDGC,iBAAiB,iBAChB,oBAAC,iBAAD,qBACE,oBAAC,WAAD;AAAa,IAAA,IAAI,EAAC,MAAlB;AAAyB,IAAA,KAAK,EAAEjC,MAAM,CAAC+E;AAAvC,IADF,eAEE,kCAAO9C,iBAAP,CAFF,CAvDJ,CADF;AA+DD,CAnKD;;;AA1BElB,EAAAA,E;AACAC,EAAAA,I;AACAM,EAAAA,S,aAAW,Q,EAAW,U,EAAa,O;AACnCC,EAAAA,M;AACAC,EAAAA,W;AACAC,EAAAA,U;AACAC,EAAAA,W;AACAC,EAAAA,U;AACAC,EAAAA,S;AACAX,EAAAA,W;AACAC,EAAAA,Q;AACAC,EAAAA,W;AACAC,EAAAA,c;AACAC,EAAAA,kB;AACAQ,EAAAA,Q;AACAC,EAAAA,M;AACAC,EAAAA,Q;AACAC,EAAAA,uB;AACAC,EAAAA,iB;AACAC,EAAAA,I,aAAO,O,EAAU,Q;AACjBC,EAAAA,M;;AA2KF,eAAerB,aAAf","sourcesContent":["import * as React from 'react';\nimport { COLORS } from '../styles';\nimport { ArrowDropDown, ArrowDropUp, Information, TechnicalWarning } from '../icons/systemicons/SystemIcons';\nimport { LoadingIndicator } from '../LoadingIndicator';\nimport { DropdownButton, Dropdown, StyledField } from './CommonStyling';\nimport DropdownContent from './DropdownContent'\nimport { AutofilledMessage, WarningMessage } from '../InputFields/styling';\nimport { DropdownItem } from './DropdownButtonTypes';\nimport { Size } from '../types';\n\ninterface DropdownFilterProps {\n id: string;\n list: string[] | DropdownItem[];\n itemsType: 'normal' | 'checkbox' | 'radio';\n action?: () => void;\n actionLabel?: string;\n pinTopItem?: boolean;\n multiSelect?: boolean;\n scrollable?: boolean;\n maxHeight?: string;\n placeholder?: string;\n onSelect?: (value: string[]) => void;\n initalValue?: string;\n disableSorting?: boolean;\n messageOnNoResults?: string;\n disabled?: boolean;\n locked?: boolean;\n isButton?: boolean;\n activeValidationMessage?: string;\n autofilledMessage?: string;\n size?: 'small' | 'medium';\n margin?: string;\n}\n\nconst MAX_MENU_HEIGHT = 240;\nconst AVG_OPTION_HEIGHT = 48;\n\nconst BasicDropdown = ({\n id,\n list,\n placeholder,\n onSelect,\n initalValue,\n disableSorting,\n messageOnNoResults,\n itemsType,\n action,\n actionLabel,\n pinTopItem,\n multiSelect,\n scrollable = true,\n maxHeight,\n disabled,\n locked,\n isButton,\n activeValidationMessage,\n autofilledMessage,\n size,\n margin = '4px 0',\n}: DropdownFilterProps) => {\n const [isOpen, setIsOpen] = React.useState<boolean>(false);\n const [isLoading, setIsLoading] = React.useState<boolean>(false);\n const [input, setInput] = React.useState<string>('');\n const [placeholderSearch, setPlaceholderSearch] = React.useState<string>(placeholder || '');\n const [restartFilter, setRestartFilter] = React.useState<boolean>(false);\n const [focused, setFocused] = React.useState<number | null>(null);\n const [selectedValues, setSelectedValues] = React.useState<string[]>([]);\n const [normalizedList, setNormalizedList] = React.useState<string[]>([]);\n\n const styledFieldRef = React.useRef<HTMLDivElement>(null);\n\n const isDropdownItem = (item: string | DropdownItem) => {\n return (item as DropdownItem).label !== undefined;\n };\n\n React.useEffect(() => {\n if (list.length > 0) {\n if (isDropdownItem(list[0])) {\n setNormalizedList((list as (string | DropdownItem)[]).map((i: string | DropdownItem) => (i as DropdownItem).label));\n } else {\n setNormalizedList((list as (string | DropdownItem)[]).map((i: string | DropdownItem) => i as string));\n }\n }\n }, [list]);\n\n /*\n if (!items.includes(input)) {\n setInput('');\n setPlaceholderSearch(placeholder || '');\n } */\n\n const handleKeyPress = (e: any) => {\n if (styledFieldRef?.current && styledFieldRef.current.contains(e.target)) {\n if (e.keyCode === 13) {\n setIsOpen(!isOpen);\n } else if (e.keyCode === 40) {\n setIsOpen(!isOpen);\n }\n }\n };\n\n const handleValueSelect = (values: string[]) => {\n \n setRestartFilter(true);\n setInput(values.join(', '));\n onSelect && onSelect(values);\n //don't close dropdown on item select if have custom action or multiselect\n if(actionLabel || multiSelect)\n return;\n\n setIsOpen(false);\n setFocused(null);\n };\n\n React.useEffect(() => {\n if (initalValue) {\n setInput(initalValue);\n setRestartFilter(true);\n }\n }, [initalValue]);\n\n React.useEffect(() => {\n document.addEventListener('keypress', handleKeyPress);\n return () => {\n document.removeEventListener('keypress', handleKeyPress);\n };\n });\n\n React.useEffect(() => {\n setIsLoading(false);\n }, [input]);\n\n const customSetIsOpen = (isOpen: boolean) => {\n console.log('dropdown content triggered');\n setIsOpen(isOpen);\n }\n\n return (\n <>\n <Dropdown isButton={isButton || false} className={size ? size : ''} locked={locked} disabled={disabled} margin={margin}>\n <StyledField\n ref={styledFieldRef}\n className={(isOpen ? 'expanded ' : '').concat(size ? size : '').concat(isButton ? 'button' : '')}\n onClick={() => {\n if (!locked || !disabled) {\n setIsOpen(!isOpen);\n }\n }}\n tabIndex={disabled || locked ? -1 : 0}\n disabled={disabled || false}\n locked={locked || false}\n showValidationMessage={!!activeValidationMessage}\n isPlaceholder={!input}>\n <div className={'value'}>{input || placeholderSearch}</div>\n {isLoading ? <LoadingIndicator size=\"small\" color={COLORS.neutral_600} /> : null}\n <div onClick={() => setIsOpen(!isOpen)} className={'icon'}>\n {isOpen ? <ArrowDropUp size=\"24px\" className={size ? size : ''} /> : <ArrowDropDown size=\"24px\" className={size ? size : ''} />}\n </div>\n </StyledField>\n {!locked && !disabled && (\n <DropdownContent\n customizationProps={{\n itemsType: itemsType,\n action: action ?? (() => {}),\n actionLabel: actionLabel,\n scrollable: scrollable,\n isButton: isButton || false,\n onValueUpdate: handleValueSelect,\n items: normalizedList.map(x => ({ value: x })),\n multiSelect: multiSelect,\n pinTopItem: pinTopItem,\n maxHeight: maxHeight\n }}\n size={size == 'medium' ? Size.Medium : Size.Small}\n filter={''}\n hideOnClickOutside={true}\n isOpen={isOpen}\n setIsOpen={customSetIsOpen}\n messageOnNoResults={messageOnNoResults ?? ''}\n isButton={isButton || false}\n selectedValues={selectedValues}\n setSelectedValues={setSelectedValues}\n id={`${id}_dropdowncontent`}\n />\n )}\n </Dropdown>\n {activeValidationMessage && (\n <WarningMessage>\n <TechnicalWarning size=\"20px\" color={COLORS.warning_400} />\n <span>{activeValidationMessage}</span>\n </WarningMessage>\n )}\n {autofilledMessage && (\n <AutofilledMessage>\n <Information size=\"20px\" color={COLORS.neutral_600} />\n <span>{autofilledMessage}</span>\n </AutofilledMessage>\n )}\n </>\n );\n};\n\nexport default BasicDropdown;\n"],"file":"BasicDropdown.js"}
@@ -14,7 +14,7 @@ import styled from 'styled-components';
14
14
  */
15
15
 
16
16
  import { InputChip } from '../Chips/index';
17
- import { Search, TechnicalWarning, User } from '../icons/systemicons/SystemIcons';
17
+ import { Search, TechnicalWarning } from '../icons/systemicons/SystemIcons';
18
18
  import { WarningMessage, ErrorMessage } from '../InputFields/styling';
19
19
  import { COLORS } from '../styles';
20
20
  /**
@@ -26,9 +26,10 @@ import { ChipInputContainer } from '../Chips/ChipStyles';
26
26
  * Import custom types.
27
27
  */
28
28
 
29
- import { DropdownButton, DropdownContent } from './CommonStyling';
29
+ import { DropdownButton } from './CommonStyling';
30
+ import DropdownContent from './DropdownContent';
30
31
  import { LoadingIndicator } from '../LoadingIndicator';
31
- import { ComponentMStyling, ComponentXXSStyling, ComponentTextStyle } from '../styles/typography';
32
+ import { ComponentMStyling, ComponentTextStyle } from '../styles/typography';
32
33
  const Wrapper = styled.div`
33
34
  position: relative;
34
35
  display: inline-block;
@@ -126,19 +127,6 @@ const StyledDropdownButton = styled(DropdownButton)`
126
127
  margin: auto 0 auto 0;
127
128
  }
128
129
  `;
129
- const DropdownButtonLabels = styled.div`
130
- display: flex;
131
- flex-direction: column;
132
- span {
133
- line-height: 24px;
134
- }
135
- `;
136
- const SecondaryLabel = styled.span`
137
- ${ComponentXXSStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}
138
- `;
139
- const SuggestionButton = styled(StyledDropdownButton)`
140
- border-bottom: 1px solid ${COLORS.neutral_200};
141
- `;
142
130
  const Loading = styled.div`
143
131
  margin: auto 16px auto auto !important;
144
132
  height: 20px;
@@ -170,12 +158,10 @@ const ChipDropdownInput = ({
170
158
  const [value, setValue] = React.useState('');
171
159
  const [dropdownIsOpen, setDropdownIsOpen] = React.useState(false);
172
160
  const [currentSearchResult, setCurrentSearchResult] = React.useState();
173
- const [restartFilter, setRestartFilter] = React.useState(false);
174
- const [focused, setFocused] = React.useState(null); // Initiate refs
161
+ const [restartFilter, setRestartFilter] = React.useState(false); // Initiate refs
175
162
 
176
163
  const chipInput = React.useRef();
177
164
  const styledFieldRef = React.useRef(null);
178
- const dropdownRef = React.useRef();
179
165
  /**
180
166
  * Sets initial values for the chips.
181
167
  */
@@ -290,110 +276,10 @@ const ChipDropdownInput = ({
290
276
  setCurrentSearchResult(options);
291
277
  }, [value, givenList, chips]);
292
278
 
293
- const getElements = () => {
294
- var number = 0;
295
-
296
- if (currentSearchResult?.length === 0 && !suggestion) {
297
- return /*#__PURE__*/React.createElement(DropdownButton, {
298
- disabled: true
299
- }, /*#__PURE__*/React.createElement("span", null, messageOnNoResults));
300
- }
301
-
302
- return /*#__PURE__*/React.createElement(React.Fragment, null, suggestion && /*#__PURE__*/React.createElement(SuggestionButton, {
303
- type: "button",
304
- tabIndex: -1,
305
- onClick: e => {
306
- e.preventDefault();
307
- setRestartFilter(true);
308
- addChip(suggestion.value);
309
- setFocused(null);
310
- chipInput?.current?.focus();
311
- },
312
- className: suggestion.value.toLowerCase() === value.toLowerCase() ? 'active' : '',
313
- key: suggestion.value,
314
- id: `${inputId}_${number++}`
315
- }, !excludeIcon && /*#__PURE__*/React.createElement(User, {
316
- size: "24px"
317
- }), suggestion.secondaryLabel ? /*#__PURE__*/React.createElement(DropdownButtonLabels, null, /*#__PURE__*/React.createElement("span", null, suggestion.label), /*#__PURE__*/React.createElement(SecondaryLabel, null, suggestion.secondaryLabel)) : /*#__PURE__*/React.createElement("span", null, suggestion.label)), currentSearchResult?.map(item => {
318
- return /*#__PURE__*/React.createElement(StyledDropdownButton, {
319
- type: "button",
320
- tabIndex: -1,
321
- onClick: e => {
322
- e.preventDefault();
323
- setRestartFilter(true);
324
- addChip(item.value);
325
- setFocused(null);
326
- chipInput?.current?.focus();
327
- },
328
- className: item.value.toLowerCase() === value.toLowerCase() ? 'active' : '',
329
- key: item.value,
330
- id: `${inputId}_${number++}`
331
- }, !excludeIcon && /*#__PURE__*/React.createElement(User, {
332
- size: "24px"
333
- }), item.secondaryLabel ? /*#__PURE__*/React.createElement(DropdownButtonLabels, null, /*#__PURE__*/React.createElement("span", null, item.label), /*#__PURE__*/React.createElement(SecondaryLabel, null, item.secondaryLabel)) : /*#__PURE__*/React.createElement("span", null, item.label));
334
- }));
335
- };
336
-
337
- const setNewFocusedElement = index => {
338
- const newFocusedElement = document.getElementById(`${inputId}_${index}`);
339
-
340
- if (newFocusedElement) {
341
- setFocused(index);
342
- newFocusedElement.focus();
343
- }
344
- };
345
-
346
- const handleKeyDown = e => {
347
- if (dropdownIsOpen) {
348
- if (e.keyCode === 38) {
349
- e.preventDefault();
350
- var focusedNow = focused;
351
-
352
- if (focusedNow !== undefined && focusedNow !== null && focusedNow > 0) {
353
- focusedNow -= 1;
354
- setNewFocusedElement(focusedNow);
355
- }
356
- } else if (e.keyCode === 40) {
357
- e.preventDefault();
358
- var focusedNow = focused;
359
-
360
- if (focusedNow !== undefined && focusedNow !== null) {
361
- focusedNow++;
362
- } else {
363
- focusedNow = 0;
364
- }
365
-
366
- setNewFocusedElement(focusedNow);
367
- } else if (e.keyCode === 9) {
368
- setDropdownIsOpen(false);
369
- } else if (e.keyCode === 27) {
370
- setDropdownIsOpen(false);
371
- setNewFocusedElement(0);
372
-
373
- if (!givenList.find(e => e.value === value)) {
374
- setValue('');
375
- }
376
-
377
- styledFieldRef.current?.focus();
378
- } else if (e.keyCode === 13) {
379
- const matches = currentSearchResult?.filter(c => c.value.toLowerCase() === value.toLowerCase());
380
-
381
- if (matches?.length === 1
382
- /*&& onSelect*/
383
- ) {
384
- addChip(matches[0].value); //onSelect(chips);
385
- } else if (e.target.value === suggestion?.label) {
386
- addChip(e.target.value);
387
- }
388
-
389
- setDropdownIsOpen(!dropdownIsOpen);
390
- setNewFocusedElement(0);
391
-
392
- if (matches?.length === 0) {
393
- setValue('');
394
- }
395
- }
396
- }
279
+ const handleValueUpdate = values => {
280
+ setRestartFilter(true);
281
+ addChip(values[0]);
282
+ chipInput?.current?.focus();
397
283
  };
398
284
 
399
285
  const handleKeyPress = e => {
@@ -410,14 +296,12 @@ const ChipDropdownInput = ({
410
296
  }
411
297
 
412
298
  setDropdownIsOpen(!dropdownIsOpen);
413
- setNewFocusedElement(0);
414
299
 
415
300
  if (matches?.length === 0) {
416
301
  setValue('');
417
302
  }
418
303
  } else if (e.keyCode === 40) {
419
304
  setDropdownIsOpen(!dropdownIsOpen);
420
- setNewFocusedElement(0);
421
305
  }
422
306
  }
423
307
  };
@@ -426,7 +310,6 @@ const ChipDropdownInput = ({
426
310
  if (styledFieldRef?.current && !styledFieldRef.current.contains(e.target)) {
427
311
  if (dropdownIsOpen) {
428
312
  setDropdownIsOpen(false);
429
- setFocused(null);
430
313
 
431
314
  if (!givenList.find(e => e.value === value)) {
432
315
  setValue('');
@@ -436,11 +319,9 @@ const ChipDropdownInput = ({
436
319
  };
437
320
 
438
321
  React.useEffect(() => {
439
- document.addEventListener('keydown', handleKeyDown);
440
322
  document.addEventListener('keypress', handleKeyPress);
441
323
  document.addEventListener('click', handleClickOutside);
442
324
  return () => {
443
- document.removeEventListener('keydown', handleKeyDown);
444
325
  document.removeEventListener('keypress', handleKeyPress);
445
326
  document.removeEventListener('click', handleClickOutside);
446
327
  };
@@ -449,6 +330,18 @@ const ChipDropdownInput = ({
449
330
  * Return Chip Input component.
450
331
  */
451
332
 
333
+ let dropdownItems = [];
334
+ if (currentSearchResult) dropdownItems = currentSearchResult.map(x => ({
335
+ value: x.value,
336
+ displayLabel: x.label,
337
+ noteLabel: x.secondaryLabel
338
+ }));
339
+ if (suggestion && !chips.includes(suggestion.value)) dropdownItems = [{
340
+ value: suggestion.value,
341
+ displayLabel: suggestion.label,
342
+ noteLabel: suggestion.secondaryLabel,
343
+ suggestion: true
344
+ }, ...dropdownItems];
452
345
  return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(StyledChipInputContainer, {
453
346
  id: inputId,
454
347
  onClick: e => {
@@ -496,11 +389,27 @@ const ChipDropdownInput = ({
496
389
  size: "small",
497
390
  color: COLORS.neutral_600
498
391
  })) : null), (!maxSelectedItems || maxSelectedItems && chips.length < maxSelectedItems) && /*#__PURE__*/React.createElement(DropdownContent, {
392
+ customizationProps: {
393
+ isButton: false,
394
+ action: () => {},
395
+ pinTopItem: true,
396
+ itemsType: 'normal',
397
+ scrollable: true,
398
+ actionLabel: '',
399
+ multiSelect: false,
400
+ onValueUpdate: handleValueUpdate,
401
+ items: dropdownItems
402
+ },
403
+ hideOnClickOutside: false,
404
+ selectedValues: [],
405
+ messageOnNoResults: messageOnNoResults ?? '',
406
+ setSelectedValues: () => {},
407
+ isOpen: dropdownIsOpen,
408
+ setIsOpen: setDropdownIsOpen,
409
+ filter: '',
499
410
  isButton: false,
500
- ref: dropdownRef,
501
- id: `${inputId}_dropdowncontent`,
502
- className: dropdownIsOpen ? 'show' : ''
503
- }, getElements()), validationMessage && validationType === 'warning' ? /*#__PURE__*/React.createElement(WarningMessage, null, /*#__PURE__*/React.createElement(TechnicalWarning, {
411
+ id: `${inputId}_dropdowncontent`
412
+ }), validationMessage && validationType === 'warning' ? /*#__PURE__*/React.createElement(WarningMessage, null, /*#__PURE__*/React.createElement(TechnicalWarning, {
504
413
  size: "20px",
505
414
  color: COLORS.critical_500
506
415
  }), /*#__PURE__*/React.createElement("span", null, validationMessage)) : validationType === 'error' && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(TechnicalWarning, {