@onewelcome/react-lib-components 6.4.4 → 6.6.0

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 (145) hide show
  1. package/dist/cjs/Form/FileUpload/FileItem/FileItem.cjs.js +1 -1
  2. package/dist/cjs/Form/FileUpload/FileItem/FileItem.cjs.js.map +1 -1
  3. package/dist/cjs/Form/FileUpload/FileItem/FileItem.module.cjs.js +2 -0
  4. package/dist/cjs/Form/FileUpload/FileItem/FileItem.module.cjs.js.map +1 -0
  5. package/dist/cjs/Form/Select/MultiSelect/MultiOption.cjs.js +1 -1
  6. package/dist/cjs/Form/Select/MultiSelect/MultiOption.cjs.js.map +1 -1
  7. package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
  8. package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
  9. package/dist/cjs/Form/Select/MultiSelect/MultiSelect.module.cjs.js +1 -1
  10. package/dist/cjs/Form/Select/MultiSelect/SelectButton.cjs.js +1 -1
  11. package/dist/cjs/Form/Select/MultiSelect/SelectButton.cjs.js.map +1 -1
  12. package/dist/cjs/Form/Select/MultiSelect/SelectButton.module.cjs.js +1 -1
  13. package/dist/cjs/Form/Select/MultiSelect/SelectedOptions.cjs.js +1 -1
  14. package/dist/cjs/Form/Select/MultiSelect/SelectedOptions.cjs.js.map +1 -1
  15. package/dist/cjs/Form/Select/MultiSelect/useArrowNavigation.cjs.js +2 -0
  16. package/dist/cjs/Form/Select/MultiSelect/useArrowNavigation.cjs.js.map +1 -0
  17. package/dist/cjs/Form/Select/MultiSelect/useSearch.cjs.js +2 -0
  18. package/dist/cjs/Form/Select/MultiSelect/useSearch.cjs.js.map +1 -0
  19. package/dist/cjs/Form/Select/SingleSelect/Option.cjs.js +1 -1
  20. package/dist/cjs/Form/Select/SingleSelect/Option.cjs.js.map +1 -1
  21. package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js +1 -1
  22. package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
  23. package/dist/cjs/Form/Select/SingleSelect/Select.module.cjs.js +1 -1
  24. package/dist/cjs/Form/Select/SingleSelect/useArrowNavigation.cjs.js +2 -0
  25. package/dist/cjs/Form/Select/SingleSelect/useArrowNavigation.cjs.js.map +1 -0
  26. package/dist/cjs/Form/Select/SingleSelect/useSearch.cjs.js +2 -0
  27. package/dist/cjs/Form/Select/SingleSelect/useSearch.cjs.js.map +1 -0
  28. package/dist/cjs/Form/Select/useAddNewBtn.cjs.js +1 -1
  29. package/dist/cjs/Form/Select/useAddNewBtn.cjs.js.map +1 -1
  30. package/dist/cjs/Form/Select/useAddNewBtn.module.cjs.js +1 -1
  31. package/dist/cjs/Form/Select/useSelectPositionList.cjs.js +2 -0
  32. package/dist/cjs/Form/Select/useSelectPositionList.cjs.js.map +1 -0
  33. package/dist/cjs/Notifications/BaseModal/BaseModalActions/BaseModalActions.cjs.js +1 -1
  34. package/dist/cjs/Notifications/BaseModal/BaseModalActions/BaseModalActions.cjs.js.map +1 -1
  35. package/dist/cjs/Notifications/Dialog/Dialog.cjs.js.map +1 -1
  36. package/dist/cjs/Notifications/Dialog/DialogTitle/DialogTitle.cjs.js +1 -1
  37. package/dist/cjs/Notifications/Dialog/DialogTitle/DialogTitle.cjs.js.map +1 -1
  38. package/dist/cjs/Tooltip/Tooltip.module.cjs.js +1 -1
  39. package/dist/cjs/src/components/Form/Select/MultiSelect/MultiSelect.test.d.ts +63 -1
  40. package/dist/cjs/src/components/Form/Select/MultiSelect/MultiSelectKeyboardNavigation.test.d.ts +1 -0
  41. package/dist/cjs/src/components/Form/Select/MultiSelect/SelectedOptions.d.ts +2 -1
  42. package/dist/cjs/src/components/Form/Select/MultiSelect/useArrowNavigation.d.ts +16 -0
  43. package/dist/cjs/src/components/Form/Select/MultiSelect/useSearch.d.ts +34 -0
  44. package/dist/cjs/src/components/Form/Select/Select.interfaces.d.ts +1 -0
  45. package/dist/cjs/src/components/Form/Select/SingleSelect/Option.d.ts +1 -0
  46. package/dist/cjs/src/components/Form/Select/SingleSelect/useArrowNavigation.d.ts +5 -0
  47. package/dist/cjs/src/components/Form/Select/{useSearch.d.ts → SingleSelect/useSearch.d.ts} +2 -1
  48. package/dist/cjs/src/components/Form/Select/useAddNewBtn.d.ts +10 -3
  49. package/dist/cjs/src/components/Form/Select/useSelectPositionList.d.ts +12 -0
  50. package/dist/cjs/src/components/Notifications/Dialog/Dialog.d.ts +1 -1
  51. package/dist/cjs/src/util/helper.cjs.js +1 -1
  52. package/dist/cjs/src/util/helper.cjs.js.map +1 -1
  53. package/dist/cjs/src/util/helper.d.ts +1 -0
  54. package/dist/esm/Form/FileUpload/FileItem/FileItem.esm.js +1 -1
  55. package/dist/esm/Form/FileUpload/FileItem/FileItem.esm.js.map +1 -1
  56. package/dist/esm/Form/FileUpload/FileItem/FileItem.module.esm.js +2 -0
  57. package/dist/esm/Form/FileUpload/FileItem/FileItem.module.esm.js.map +1 -0
  58. package/dist/esm/Form/Select/MultiSelect/MultiOption.esm.js +1 -1
  59. package/dist/esm/Form/Select/MultiSelect/MultiOption.esm.js.map +1 -1
  60. package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js +1 -1
  61. package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js.map +1 -1
  62. package/dist/esm/Form/Select/MultiSelect/MultiSelect.module.esm.js +1 -1
  63. package/dist/esm/Form/Select/MultiSelect/SelectButton.esm.js +1 -1
  64. package/dist/esm/Form/Select/MultiSelect/SelectButton.esm.js.map +1 -1
  65. package/dist/esm/Form/Select/MultiSelect/SelectButton.module.esm.js +1 -1
  66. package/dist/esm/Form/Select/MultiSelect/SelectedOptions.esm.js +1 -1
  67. package/dist/esm/Form/Select/MultiSelect/SelectedOptions.esm.js.map +1 -1
  68. package/dist/esm/Form/Select/MultiSelect/useArrowNavigation.esm.js +2 -0
  69. package/dist/esm/Form/Select/MultiSelect/useArrowNavigation.esm.js.map +1 -0
  70. package/dist/esm/Form/Select/MultiSelect/useSearch.esm.js +2 -0
  71. package/dist/esm/Form/Select/MultiSelect/useSearch.esm.js.map +1 -0
  72. package/dist/esm/Form/Select/SingleSelect/Option.esm.js +1 -1
  73. package/dist/esm/Form/Select/SingleSelect/Option.esm.js.map +1 -1
  74. package/dist/esm/Form/Select/SingleSelect/Select.esm.js +1 -1
  75. package/dist/esm/Form/Select/SingleSelect/Select.esm.js.map +1 -1
  76. package/dist/esm/Form/Select/SingleSelect/Select.module.esm.js +1 -1
  77. package/dist/esm/Form/Select/SingleSelect/useArrowNavigation.esm.js +2 -0
  78. package/dist/esm/Form/Select/SingleSelect/useArrowNavigation.esm.js.map +1 -0
  79. package/dist/esm/Form/Select/SingleSelect/useSearch.esm.js +2 -0
  80. package/dist/esm/Form/Select/SingleSelect/useSearch.esm.js.map +1 -0
  81. package/dist/esm/Form/Select/useAddNewBtn.esm.js +1 -1
  82. package/dist/esm/Form/Select/useAddNewBtn.esm.js.map +1 -1
  83. package/dist/esm/Form/Select/useAddNewBtn.module.esm.js +1 -1
  84. package/dist/esm/Form/Select/useSelectPositionList.esm.js +2 -0
  85. package/dist/esm/Form/Select/useSelectPositionList.esm.js.map +1 -0
  86. package/dist/esm/Notifications/BaseModal/BaseModalActions/BaseModalActions.esm.js +1 -1
  87. package/dist/esm/Notifications/BaseModal/BaseModalActions/BaseModalActions.esm.js.map +1 -1
  88. package/dist/esm/Notifications/Dialog/Dialog.esm.js.map +1 -1
  89. package/dist/esm/Notifications/Dialog/DialogTitle/DialogTitle.esm.js +1 -1
  90. package/dist/esm/Notifications/Dialog/DialogTitle/DialogTitle.esm.js.map +1 -1
  91. package/dist/esm/Tooltip/Tooltip.module.esm.js +1 -1
  92. package/dist/esm/src/components/Form/Select/MultiSelect/MultiSelect.test.d.ts +63 -1
  93. package/dist/esm/src/components/Form/Select/MultiSelect/MultiSelectKeyboardNavigation.test.d.ts +1 -0
  94. package/dist/esm/src/components/Form/Select/MultiSelect/SelectedOptions.d.ts +2 -1
  95. package/dist/esm/src/components/Form/Select/MultiSelect/useArrowNavigation.d.ts +16 -0
  96. package/dist/esm/src/components/Form/Select/MultiSelect/useSearch.d.ts +34 -0
  97. package/dist/esm/src/components/Form/Select/Select.interfaces.d.ts +1 -0
  98. package/dist/esm/src/components/Form/Select/SingleSelect/Option.d.ts +1 -0
  99. package/dist/esm/src/components/Form/Select/SingleSelect/useArrowNavigation.d.ts +5 -0
  100. package/dist/esm/src/components/Form/Select/{useSearch.d.ts → SingleSelect/useSearch.d.ts} +2 -1
  101. package/dist/esm/src/components/Form/Select/useAddNewBtn.d.ts +10 -3
  102. package/dist/esm/src/components/Form/Select/useSelectPositionList.d.ts +12 -0
  103. package/dist/esm/src/components/Notifications/Dialog/Dialog.d.ts +1 -1
  104. package/dist/esm/src/util/helper.d.ts +1 -0
  105. package/dist/esm/src/util/helper.esm.js +1 -1
  106. package/dist/esm/src/util/helper.esm.js.map +1 -1
  107. package/package.json +6 -6
  108. package/src/components/Form/FileUpload/FileItem/FileItem.tsx +1 -1
  109. package/src/components/Form/Select/MultiSelect/MultiOption.tsx +36 -3
  110. package/src/components/Form/Select/MultiSelect/MultiSelect.module.scss +29 -19
  111. package/src/components/Form/Select/MultiSelect/MultiSelect.tsx +85 -62
  112. package/src/components/Form/Select/MultiSelect/SelectButton.module.scss +1 -1
  113. package/src/components/Form/Select/MultiSelect/SelectButton.tsx +1 -1
  114. package/src/components/Form/Select/MultiSelect/SelectedOptions.tsx +5 -4
  115. package/src/components/Form/Select/MultiSelect/useArrowNavigation.ts +128 -0
  116. package/src/components/Form/Select/MultiSelect/useSearch.tsx +126 -0
  117. package/src/components/Form/Select/Select.interfaces.ts +1 -0
  118. package/src/components/Form/Select/SingleSelect/Option.tsx +15 -4
  119. package/src/components/Form/Select/SingleSelect/Select.module.scss +13 -2
  120. package/src/components/Form/Select/SingleSelect/Select.tsx +7 -3
  121. package/src/components/Form/Select/{SelectService.ts → SingleSelect/useArrowNavigation.ts} +1 -101
  122. package/src/components/Form/Select/{useSearch.tsx → SingleSelect/useSearch.tsx} +3 -2
  123. package/src/components/Form/Select/useAddNewBtn.module.scss +18 -4
  124. package/src/components/Form/Select/useAddNewBtn.tsx +42 -8
  125. package/src/components/Form/Select/useSelectPositionList.ts +113 -0
  126. package/src/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +1 -1
  127. package/src/components/Notifications/Dialog/Dialog.tsx +1 -1
  128. package/src/components/Notifications/Dialog/DialogTitle/DialogTitle.tsx +5 -3
  129. package/src/components/Tooltip/Tooltip.module.scss +1 -1
  130. package/src/util/helper.tsx +2 -0
  131. package/dist/cjs/Form/FileUpload/FileItem/FileItem.modules.cjs.js +0 -2
  132. package/dist/cjs/Form/FileUpload/FileItem/FileItem.modules.cjs.js.map +0 -1
  133. package/dist/cjs/Form/Select/SelectService.cjs.js +0 -2
  134. package/dist/cjs/Form/Select/SelectService.cjs.js.map +0 -1
  135. package/dist/cjs/Form/Select/useSearch.cjs.js +0 -2
  136. package/dist/cjs/Form/Select/useSearch.cjs.js.map +0 -1
  137. package/dist/cjs/src/components/Form/Select/SelectService.d.ts +0 -17
  138. package/dist/esm/Form/FileUpload/FileItem/FileItem.modules.esm.js +0 -2
  139. package/dist/esm/Form/FileUpload/FileItem/FileItem.modules.esm.js.map +0 -1
  140. package/dist/esm/Form/Select/SelectService.esm.js +0 -2
  141. package/dist/esm/Form/Select/SelectService.esm.js.map +0 -1
  142. package/dist/esm/Form/Select/useSearch.esm.js +0 -2
  143. package/dist/esm/Form/Select/useSearch.esm.js.map +0 -1
  144. package/dist/esm/src/components/Form/Select/SelectService.d.ts +0 -17
  145. /package/src/components/Form/FileUpload/FileItem/{FileItem.modules.scss → FileItem.module.scss} +0 -0
@@ -125,8 +125,19 @@ $listItemHeight: 2.5rem;
125
125
  cursor: pointer;
126
126
 
127
127
  &:focus {
128
- outline: var(--input-border-width-focus) solid var(--color-primary300);
129
- outline-offset: var(--input-border-width-focus);
128
+ outline: none;
129
+
130
+ &::before {
131
+ @include mixins.focusVisibleOutline($outlineOffset: 0, $selectors: null);
132
+ content: "";
133
+ position: absolute;
134
+ top: 0;
135
+ left: 0.125rem;
136
+ height: 100%;
137
+ width: calc(100% - 0.25rem);
138
+ opacity: 1;
139
+ z-index: calc(variables.$popover-z-index + 1);
140
+ }
130
141
  }
131
142
 
132
143
  &:hover {
@@ -31,9 +31,10 @@ import readyclasses from "../../../../readyclasses.module.scss";
31
31
  import { filterProps } from "../../../../util/helper";
32
32
  import { Icon, Icons } from "../../../Icon/Icon";
33
33
  import { SingleSelectProps } from "../Select.interfaces";
34
- import { useArrowNavigation, useSelectPositionList } from "../SelectService";
34
+ import { useSelectPositionList } from "../useSelectPositionList";
35
35
  import { useAddNewBtn } from "../useAddNewBtn";
36
- import { useSearch } from "../useSearch";
36
+ import { useSearch } from "./useSearch";
37
+ import { useArrowNavigation } from "./useArrowNavigation";
37
38
 
38
39
  const SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectProps> = (
39
40
  {
@@ -87,7 +88,10 @@ const SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectP
87
88
  });
88
89
  const { addBtnRef, addNewBtnOptionsContainerClassName, renderAddNew } = useAddNewBtn({
89
90
  addNew,
90
- filter
91
+ filter,
92
+ focusedSelectItem,
93
+ optionsCount,
94
+ searchInputRef
91
95
  });
92
96
 
93
97
  const nativeSelect = (ref as React.RefObject<HTMLSelectElement>) || createRef();
@@ -14,12 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { useEffect, useState } from "react";
18
- import {
19
- Position,
20
- UseArrowNavigationParams,
21
- UseSelectPositionListParams
22
- } from "./Select.interfaces";
17
+ import { UseArrowNavigationParams } from "../Select.interfaces";
23
18
 
24
19
  /** @scope .*/
25
20
  export const useArrowNavigation = ({
@@ -175,98 +170,3 @@ export const useArrowNavigation = ({
175
170
 
176
171
  return { onArrowNavigation };
177
172
  };
178
-
179
- /** @scope .*/
180
- export const useSelectPositionList = ({
181
- expanded,
182
- optionListReference,
183
- addBtnRef,
184
- containerReference
185
- }: UseSelectPositionListParams) => {
186
- const [optionsListMaxHeight, setOptionsListMaxHeight] = useState<{
187
- wrapper?: string;
188
- list?: string;
189
- }>({
190
- wrapper: undefined,
191
- list: undefined
192
- });
193
- const [opacity, setOpacity] = useState(0); // We set opacity because otherwise if we calculate the max height you see the list full height for a split second and then it shortens.
194
- const [listPosition, setListPosition] = useState<Partial<Position>>({});
195
-
196
- useEffect(() => {
197
- rePositionList();
198
- }, [expanded]);
199
-
200
- const rePositionList = () => {
201
- if (!expanded || !optionListReference.current || !containerReference.current) {
202
- return;
203
- }
204
-
205
- // Check whether there is more space above or below the select
206
- // Check space between the bottom of select and top of viewport
207
- const spaceOnTopOfSelect = containerReference.current.getBoundingClientRect().bottom;
208
-
209
- // Check space between the top of the select and bottom of viewport
210
- const spaceOnBottomOfSelect =
211
- window.innerHeight - containerReference.current.getBoundingClientRect().top;
212
-
213
- // Set position as if there's more space on the bottom
214
- let position: Position = { top: "2.75rem", bottom: "initial" };
215
-
216
- // Set the position of the select
217
- if (spaceOnTopOfSelect > spaceOnBottomOfSelect) {
218
- position = { top: "initial", bottom: "2.75rem" };
219
- }
220
-
221
- setListPosition(position);
222
-
223
- // Calculate the potential max height of the options list
224
- calculateOptionListMaxHeight(position);
225
- };
226
-
227
- const calculateOptionListMaxHeight = (position: Position) => {
228
- // Calculate max height if there's more space below the select
229
- const listHeight = optionListReference.current?.getBoundingClientRect().height;
230
- const addNewButtonHeightWithMargin = addBtnRef.current
231
- ? addBtnRef.current.getBoundingClientRect().height +
232
- parseInt(getComputedStyle(addBtnRef.current).marginBottom)
233
- : 0;
234
- const transformOrigin = position.top !== "initial" ? "top" : "bottom";
235
-
236
- if (!containerReference.current) {
237
- console.error(
238
- "The containerReference is empty for some reason in the SelectService.ts for the Select component in react-lib-components. We are trying to calculate the option list max height on expand"
239
- );
240
- return;
241
- }
242
-
243
- const availableSpace =
244
- transformOrigin === "top"
245
- ? window.innerHeight - containerReference.current.getBoundingClientRect().bottom - 16
246
- : containerReference.current.getBoundingClientRect().top - 16;
247
-
248
- if (listHeight && availableSpace < listHeight + addNewButtonHeightWithMargin) {
249
- const maxHeightObject = {
250
- wrapper: `${availableSpace}px`,
251
- list:
252
- addNewButtonHeightWithMargin > 0
253
- ? `${availableSpace - addNewButtonHeightWithMargin}px`
254
- : "none"
255
- };
256
- setOptionsListMaxHeight(maxHeightObject);
257
- setOpacity(100);
258
- return;
259
- }
260
-
261
- setOptionsListMaxHeight({ wrapper: undefined, list: undefined });
262
- setOpacity(100);
263
- };
264
-
265
- return {
266
- optionsListMaxHeight,
267
- opacity,
268
- setOpacity,
269
- listPosition,
270
- setListPosition
271
- };
272
- };
@@ -15,8 +15,8 @@
15
15
  */
16
16
 
17
17
  import React, { useEffect, useRef, useState } from "react";
18
- import { PartialInputProps, SearchProps } from "./Select.interfaces";
19
- import { Input } from "../Input/Input";
18
+ import { PartialInputProps, SearchProps } from "../Select.interfaces";
19
+ import { Input } from "../../Input/Input";
20
20
 
21
21
  interface Props {
22
22
  search?: SearchProps;
@@ -34,6 +34,7 @@ interface Props {
34
34
  setFocusedSelectItem: (idx: number) => void;
35
35
  }
36
36
 
37
+ /** @scope .*/
37
38
  export const useSearch = ({
38
39
  search,
39
40
  optionsCount,
@@ -13,12 +13,15 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ @use "src/mixins.module";
17
+ @use "src/variables";
16
18
 
17
19
  ul.has-sibling {
18
20
  padding-bottom: 2px;
19
21
  }
20
22
 
21
23
  .action-button {
24
+ position: relative;
22
25
  border: none;
23
26
  border-top: 1px solid var(--color-blue-grey50);
24
27
  width: 100%;
@@ -35,10 +38,21 @@ ul.has-sibling {
35
38
  font-family: var(--font-family);
36
39
  font-size: var(--form-control-font-size);
37
40
 
38
- &:focus {
39
- outline: 1px solid;
40
- outline-offset: 0;
41
- border-radius: 0;
41
+ &:focus,
42
+ &.focus {
43
+ outline: none;
44
+
45
+ &::before {
46
+ @include mixins.focusVisibleOutline($outlineOffset: 0, $selectors: null);
47
+ content: "";
48
+ position: absolute;
49
+ top: 0;
50
+ left: 0.125rem;
51
+ height: 100%;
52
+ width: calc(100% - 0.25rem);
53
+ opacity: 1;
54
+ z-index: calc(variables.$popover-z-index + 1);
55
+ }
42
56
  }
43
57
 
44
58
  &:hover {
@@ -16,28 +16,62 @@
16
16
 
17
17
  import classes from "./useAddNewBtn.module.scss";
18
18
 
19
- import React, { useRef } from "react";
19
+ import React, { RefObject, useEffect, useRef } from "react";
20
20
  import { AddNewProps } from "./Select.interfaces";
21
21
 
22
22
  interface Props {
23
+ id?: string;
23
24
  addNew?: AddNewProps;
24
25
  filter: string;
26
+ focusedSelectItem: number;
27
+ optionsCount: number;
28
+ searchInputRef: RefObject<HTMLInputElement>;
29
+ shouldClick?: boolean;
30
+ onClickCallback?: () => void;
25
31
  }
26
32
 
27
- export const useAddNewBtn = ({ addNew, filter }: Props) => {
33
+ /** @scope .*/
34
+ export const useAddNewBtn = ({
35
+ id,
36
+ addNew,
37
+ filter,
38
+ focusedSelectItem,
39
+ optionsCount,
40
+ searchInputRef,
41
+ shouldClick,
42
+ onClickCallback
43
+ }: Props) => {
28
44
  const addBtnRef = useRef<HTMLButtonElement>(null);
29
-
30
45
  const addNewLabel = addNew?.label ?? "Create new";
46
+ const isProgrammaticallyFocused = focusedSelectItem === optionsCount;
47
+ const isSearchDisabled = !searchInputRef.current;
48
+ const hasSearchQuery = typeof filter === "string" && !!filter.trim() && !!searchInputRef.current;
49
+ const shouldRender = addNew && (isSearchDisabled || hasSearchQuery || addNew.alwaysEnabled);
50
+
51
+ const additionalClasses = [classes["action-button"]];
52
+ addNew?.btnProps?.className && additionalClasses.push(addNew?.btnProps?.className);
53
+ isProgrammaticallyFocused && additionalClasses.push(classes["focus"]);
54
+
55
+ useEffect(() => {
56
+ const addBtnClicked = addBtnRef.current && isProgrammaticallyFocused && shouldClick;
57
+ if (addBtnClicked) {
58
+ addBtnRef.current.click();
59
+ }
60
+ }, [addBtnRef.current, isProgrammaticallyFocused, shouldClick]);
31
61
 
32
62
  const renderAddNew = () =>
33
- addNew && (
63
+ shouldRender && (
34
64
  <button
35
- data-testid={"select-action-button"}
36
- className={classes["action-button"]}
37
- onClick={() => addNew.onAddNew(filter)}
65
+ data-testid="select-action-button"
66
+ {...addNew.btnProps}
38
67
  ref={addBtnRef}
39
68
  type="button"
40
- {...addNew.btnProps}
69
+ className={additionalClasses.join(" ")}
70
+ onClick={() => {
71
+ addNew.onAddNew(filter);
72
+ onClickCallback?.();
73
+ }}
74
+ id={id}
41
75
  >
42
76
  {!filter && addNewLabel}
43
77
  {filter && <span style={{ fontWeight: "700" }}>{`"${filter}"`}</span>}
@@ -0,0 +1,113 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { useEffect, useState } from "react";
18
+ import { Position, UseSelectPositionListParams } from "./Select.interfaces";
19
+
20
+ /** @scope .*/
21
+ export const useSelectPositionList = ({
22
+ expanded,
23
+ optionListReference,
24
+ addBtnRef,
25
+ containerReference
26
+ }: UseSelectPositionListParams) => {
27
+ const [optionsListMaxHeight, setOptionsListMaxHeight] = useState<{
28
+ wrapper?: string;
29
+ list?: string;
30
+ }>({
31
+ wrapper: undefined,
32
+ list: undefined
33
+ });
34
+ const [opacity, setOpacity] = useState(0); // We set opacity because otherwise if we calculate the max height you see the list full height for a split second and then it shortens.
35
+ const [listPosition, setListPosition] = useState<Partial<Position>>({});
36
+
37
+ useEffect(() => {
38
+ rePositionList();
39
+ }, [expanded]);
40
+
41
+ const rePositionList = () => {
42
+ if (!expanded || !optionListReference.current || !containerReference.current) {
43
+ return;
44
+ }
45
+
46
+ // Check whether there is more space above or below the select
47
+ // Check space between the bottom of select and top of viewport
48
+ const spaceOnTopOfSelect = containerReference.current.getBoundingClientRect().bottom;
49
+
50
+ // Check space between the top of the select and bottom of viewport
51
+ const spaceOnBottomOfSelect =
52
+ window.innerHeight - containerReference.current.getBoundingClientRect().top;
53
+
54
+ // Set position as if there's more space on the bottom
55
+ let position: Position = { top: "2.75rem", bottom: "initial" };
56
+
57
+ // Set the position of the select
58
+ if (spaceOnTopOfSelect > spaceOnBottomOfSelect) {
59
+ position = { top: "initial", bottom: "2.75rem" };
60
+ }
61
+
62
+ setListPosition(position);
63
+
64
+ // Calculate the potential max height of the options list
65
+ calculateOptionListMaxHeight(position);
66
+ };
67
+
68
+ const calculateOptionListMaxHeight = (position: Position) => {
69
+ // Calculate max height if there's more space below the select
70
+ const listHeight = optionListReference.current?.getBoundingClientRect().height;
71
+ const addNewButtonHeightWithMargin = addBtnRef.current
72
+ ? addBtnRef.current.getBoundingClientRect().height +
73
+ parseInt(getComputedStyle(addBtnRef.current).marginBottom)
74
+ : 0;
75
+ const transformOrigin = position.top !== "initial" ? "top" : "bottom";
76
+
77
+ if (!containerReference.current) {
78
+ console.error(
79
+ "The containerReference is empty for some reason in the SelectService.ts for the Select component in react-lib-components. We are trying to calculate the option list max height on expand"
80
+ );
81
+ return;
82
+ }
83
+
84
+ const availableSpace =
85
+ transformOrigin === "top"
86
+ ? window.innerHeight - containerReference.current.getBoundingClientRect().bottom - 16
87
+ : containerReference.current.getBoundingClientRect().top - 16;
88
+
89
+ if (listHeight && availableSpace < listHeight + addNewButtonHeightWithMargin) {
90
+ const maxHeightObject = {
91
+ wrapper: `${availableSpace}px`,
92
+ list:
93
+ addNewButtonHeightWithMargin > 0
94
+ ? `${availableSpace - addNewButtonHeightWithMargin}px`
95
+ : "none"
96
+ };
97
+ setOptionsListMaxHeight(maxHeightObject);
98
+ setOpacity(100);
99
+ return;
100
+ }
101
+
102
+ setOptionsListMaxHeight({ wrapper: undefined, list: undefined });
103
+ setOpacity(100);
104
+ };
105
+
106
+ return {
107
+ optionsListMaxHeight,
108
+ opacity,
109
+ setOpacity,
110
+ listPosition,
111
+ setListPosition
112
+ };
113
+ };
@@ -46,7 +46,7 @@ const BaseModalActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props>
46
46
 
47
47
  return (
48
48
  <div {...rest} ref={innerRef} className={`${classes["actions"]} ${className}`}>
49
- {cancelAction && (
49
+ {cancelAction && onClose && (
50
50
  <div
51
51
  className={`${classes["cancel-action"]} ${cancelActionsClassName}`}
52
52
  ref={cancelButtonRef}
@@ -29,7 +29,7 @@ export interface Props extends ComponentPropsWithRef<"div"> {
29
29
  id?: string;
30
30
  open: boolean;
31
31
  children: React.ReactNode;
32
- onClose: () => void;
32
+ onClose?: () => void;
33
33
  title: string;
34
34
  primaryAction: Action;
35
35
  secondaryAction?: Action;
@@ -63,9 +63,11 @@ const DialogTitleComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
63
63
  )}
64
64
  </div>
65
65
  </div>
66
- <IconButton onClick={onClose} className={classes["close-button"]} title="close modal">
67
- <Icon icon={Icons.Times} />
68
- </IconButton>
66
+ {onClose && (
67
+ <IconButton onClick={onClose} className={classes["close-button"]} title="close modal">
68
+ <Icon icon={Icons.Times} />
69
+ </IconButton>
70
+ )}
69
71
  </div>
70
72
  );
71
73
  };
@@ -174,7 +174,7 @@
174
174
  transform-origin: center center;
175
175
  pointer-events: none;
176
176
  box-shadow: 0 0.0625rem 0.3125rem 0 rgba(1, 5, 50, 0.3);
177
- word-break: break-all;
177
+ word-break: break-word;
178
178
 
179
179
  @include mixins.transition($transition-property, 0.2s, ease-in-out);
180
180
 
@@ -217,3 +217,5 @@ export const deepMerge = <T extends {}>(obj1: ObjectType, obj2: ObjectType | fal
217
217
 
218
218
  return result as T;
219
219
  };
220
+
221
+ export const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});var e=require("../../../node_modules/style-inject/dist/style-inject.es.cjs.js");var i='/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.FileItem-modules_sr-only__OwtI4{clip:rect(0,0,0,0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.FileItem-modules_hidden__w5rVy{display:none}.FileItem-modules_slide-in__g2fUZ{animation:FileItem-modules_slide-in__g2fUZ .5s forwards}@media (prefers-reduced-motion:reduce){.FileItem-modules_slide-in__g2fUZ{animation-duration:.1ms}}.FileItem-modules_slide-out__-dBYM{animation:FileItem-modules_slide-out__-dBYM .5s forwards}@media (prefers-reduced-motion:reduce){.FileItem-modules_slide-out__-dBYM{animation-duration:.1ms}}@keyframes FileItem-modules_slide-in__g2fUZ{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes FileItem-modules_slide-out__-dBYM{0%{transform:translateY(0)}to{transform:translateY(100vh)}}.FileItem-modules_file-item-wrapper__r4sb5{background-color:var(--input-background-color);border-radius:var(--input-border-radius);padding:.5rem 1.25rem;transition-duration:.2s;transition-property:all;transition-timing-function:ease-in-out}@media (prefers-reduced-motion:reduce){.FileItem-modules_file-item-wrapper__r4sb5{transition-duration:.1ms}}.FileItem-modules_file-item-wrapper__r4sb5 [class*=icon]{font-size:1.25rem}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_progress-bar__kVAJi{background-color:var(--color-black10)}.FileItem-modules_file-item-wrapper__r4sb5 span[class*=bar--]{border-radius:var(--input-border-radius);height:1rem}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_file-name__twzQ4{align-items:center;display:flex;margin:0}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_file-name__twzQ4 .FileItem-modules_friendly-name__p3xgX{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_action-icon__ODWUg{color:var(--color-primary);cursor:pointer;margin-left:auto;padding-left:1.25rem}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_file-icon__TbFi8{margin-right:.5rem}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_file-subtitle__TmXvr,.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_progress-bar__kVAJi{display:block;margin:.3125rem 1.75rem;padding:0}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_error__Q1RuV,.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_retry__2Euk8{color:var(--error)}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_readonly__Jxi46{color:var(--greyed-out)}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkZpbGVJdGVtLm1vZHVsZXMuc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7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sZS1pdGVtLXdyYXBwZXIgLmVycm9yLFxuLmZpbGUtaXRlbS13cmFwcGVyIC5yZXRyeSB7XG4gIGNvbG9yOiB2YXIoLS1lcnJvcik7XG59XG4uZmlsZS1pdGVtLXdyYXBwZXIgLnJlYWRvbmx5IHtcbiAgY29sb3I6IHZhcigtLWdyZXllZC1vdXQpO1xufSJdfQ== */';var l={"sr-only":"FileItem-modules_sr-only__OwtI4",hidden:"FileItem-modules_hidden__w5rVy","slide-in":"FileItem-modules_slide-in__g2fUZ","slide-out":"FileItem-modules_slide-out__-dBYM","file-item-wrapper":"FileItem-modules_file-item-wrapper__r4sb5","progress-bar":"FileItem-modules_progress-bar__kVAJi","file-name":"FileItem-modules_file-name__twzQ4","friendly-name":"FileItem-modules_friendly-name__p3xgX","action-icon":"FileItem-modules_action-icon__ODWUg","file-icon":"FileItem-modules_file-icon__TbFi8","file-subtitle":"FileItem-modules_file-subtitle__TmXvr",error:"FileItem-modules_error__Q1RuV",retry:"FileItem-modules_retry__2Euk8",readonly:"FileItem-modules_readonly__Jxi46"};e["default"](i);exports["default"]=l;
2
- //# sourceMappingURL=FileItem.modules.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileItem.modules.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});var e=require("react");const t=({expanded:e,setExpanded:t,isSearching:r,setIsSearching:n,setFocusedSelectItem:o,onOptionChangeHandler:i,childrenCount:c,setShouldClick:s,searchInputRef:a,addBtnRef:u,renderThreshold:l})=>{const d=d=>{var p;const f=["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Space","Escape","End","Home"];const g=["ArrowDown","ArrowUp","Enter","Escape","MetaLeft","MetaRight"];const h=(u===null||u===void 0?void 0:u.current)===document.activeElement;if(e)f.push("Tab");if(u)g.push("Tab");if(f.includes(d.code)&&!d.metaKey&&!r)d.preventDefault();if(r&&g.includes(d.code))d.preventDefault();if(r)switch(d.code){case"ArrowDown":case"Enter":n(false);o(0);return;case"ArrowUp":n(false);o(c-1);return;case"Escape":n(false);t(false);return;case"Tab":if(u===null||u===void 0?void 0:u.current){u.current.focus();return}n(false);t(false)}else switch(d.code){case"ArrowDown":if(!e){t(true);o(0);return}o((e=>e+1>c-1?0:e+1));return;case"ArrowUp":if(!e){t(true);o(c-1);return}o((e=>e-1<0?c-1:e-1));return;case"Space":if(!e){t(true);o(0);return}i(d.target);s(true);t(false);return;case"Enter":case"Home":o(0);return;case"Tab":if(c>=l&&e&&!h){n(true);(p=a.current)===null||p===void 0?void 0:p.focus();return}else if((u===null||u===void 0?void 0:u.current)&&e&&!h){u.current.focus();return}t(false);return;case"Escape":if(e)t(false);return;case"End":o(c-1);return;case"ArrowLeft":if(d.metaKey&&e){d.preventDefault();o(0)}return;case"ArrowRight":if(d.metaKey&&e){d.preventDefault();o(c-1)}return}};return{onArrowNavigation:d}};const r=({expanded:t,optionListReference:r,addBtnRef:n,containerReference:o})=>{const[i,c]=e.useState({wrapper:void 0,list:void 0});const[s,a]=e.useState(0);const[u,l]=e.useState({});e.useEffect((()=>{d()}),[t]);const d=()=>{if(!t||!r.current||!o.current)return;const e=o.current.getBoundingClientRect().bottom;const n=window.innerHeight-o.current.getBoundingClientRect().top;let i={top:"2.75rem",bottom:"initial"};if(e>n)i={top:"initial",bottom:"2.75rem"};l(i);p(i)};const p=e=>{var t;const i=(t=r.current)===null||t===void 0?void 0:t.getBoundingClientRect().height;const s=n.current?n.current.getBoundingClientRect().height+parseInt(getComputedStyle(n.current).marginBottom):0;const u=e.top!=="initial"?"top":"bottom";if(!o.current){console.error("The containerReference is empty for some reason in the SelectService.ts for the Select component in react-lib-components. We are trying to calculate the option list max height on expand");return}const l=u==="top"?window.innerHeight-o.current.getBoundingClientRect().bottom-16:o.current.getBoundingClientRect().top-16;if(i&&l<i+s){const e={wrapper:`${l}px`,list:s>0?`${l-s}px`:"none"};c(e);a(100);return}c({wrapper:void 0,list:void 0});a(100)};return{optionsListMaxHeight:i,opacity:s,setOpacity:a,listPosition:u,setListPosition:l}};exports.useArrowNavigation=t;exports.useSelectPositionList=r;
2
- //# sourceMappingURL=SelectService.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectService.cjs.js","sources":["../../../../../../src/components/Form/Select/SelectService.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useState } from \"react\";\nimport {\n Position,\n UseArrowNavigationParams,\n UseSelectPositionListParams\n} from \"./Select.interfaces\";\n\n/** @scope .*/\nexport const useArrowNavigation = ({\n expanded,\n setExpanded,\n isSearching,\n setIsSearching,\n setFocusedSelectItem,\n onOptionChangeHandler,\n childrenCount,\n setShouldClick,\n searchInputRef,\n addBtnRef,\n renderThreshold\n}: UseArrowNavigationParams) => {\n const onArrowNavigation = (event: React.KeyboardEvent) => {\n const codesToPreventDefault = [\n \"ArrowDown\",\n \"ArrowUp\",\n \"ArrowLeft\",\n \"ArrowRight\",\n \"Space\",\n \"Escape\",\n \"End\",\n \"Home\"\n ];\n\n const codesToPreventDefaultWhenSearching = [\n \"ArrowDown\",\n \"ArrowUp\",\n \"Enter\",\n \"Escape\",\n \"MetaLeft\",\n \"MetaRight\"\n ];\n\n const isAddBtnFocused = addBtnRef?.current === document.activeElement;\n\n if (expanded) {\n codesToPreventDefault.push(\"Tab\");\n }\n\n if (addBtnRef) {\n codesToPreventDefaultWhenSearching.push(\"Tab\");\n }\n\n if (codesToPreventDefault.includes(event.code) && !event.metaKey && !isSearching) {\n event.preventDefault();\n }\n\n if (isSearching && codesToPreventDefaultWhenSearching.includes(event.code)) {\n event.preventDefault();\n }\n\n if (isSearching) {\n switch (event.code) {\n case \"ArrowDown\":\n case \"Enter\":\n setIsSearching(false);\n setFocusedSelectItem(0);\n return;\n case \"ArrowUp\":\n setIsSearching(false);\n setFocusedSelectItem(childrenCount - 1);\n return;\n case \"Escape\":\n setIsSearching(false);\n setExpanded(false);\n return;\n case \"Tab\":\n if (addBtnRef?.current) {\n addBtnRef.current.focus();\n return;\n }\n setIsSearching(false);\n setExpanded(false);\n }\n } else {\n switch (event.code) {\n case \"ArrowDown\":\n if (!expanded) {\n setExpanded(true);\n setFocusedSelectItem(0);\n return;\n }\n setFocusedSelectItem(prevState => {\n return prevState + 1 > childrenCount - 1 ? 0 : prevState + 1;\n });\n return;\n case \"ArrowUp\":\n if (!expanded) {\n setExpanded(true);\n setFocusedSelectItem(childrenCount - 1);\n return;\n }\n\n setFocusedSelectItem(prevState => {\n return prevState - 1 < 0 ? childrenCount - 1 : prevState - 1;\n });\n return;\n case \"Space\":\n if (!expanded) {\n setExpanded(true);\n setFocusedSelectItem(0);\n return;\n }\n\n onOptionChangeHandler(event.target as HTMLElement);\n setShouldClick(true);\n setExpanded(false);\n\n return;\n case \"Enter\":\n case \"Home\":\n setFocusedSelectItem(0);\n\n return;\n case \"Tab\":\n if (childrenCount >= renderThreshold && expanded && !isAddBtnFocused) {\n setIsSearching(true);\n searchInputRef.current?.focus();\n return;\n } else if (addBtnRef?.current && expanded && !isAddBtnFocused) {\n addBtnRef.current.focus();\n return;\n }\n setExpanded(false);\n\n return;\n case \"Escape\":\n if (expanded) {\n setExpanded(false);\n }\n return;\n case \"End\":\n setFocusedSelectItem(childrenCount - 1);\n return;\n case \"ArrowLeft\":\n if (event.metaKey && expanded) {\n event.preventDefault();\n setFocusedSelectItem(0);\n }\n return;\n case \"ArrowRight\":\n if (event.metaKey && expanded) {\n event.preventDefault();\n setFocusedSelectItem(childrenCount - 1);\n }\n return;\n }\n }\n };\n\n return { onArrowNavigation };\n};\n\n/** @scope .*/\nexport const useSelectPositionList = ({\n expanded,\n optionListReference,\n addBtnRef,\n containerReference\n}: UseSelectPositionListParams) => {\n const [optionsListMaxHeight, setOptionsListMaxHeight] = useState<{\n wrapper?: string;\n list?: string;\n }>({\n wrapper: undefined,\n list: undefined\n });\n const [opacity, setOpacity] = useState(0); // We set opacity because otherwise if we calculate the max height you see the list full height for a split second and then it shortens.\n const [listPosition, setListPosition] = useState<Partial<Position>>({});\n\n useEffect(() => {\n rePositionList();\n }, [expanded]);\n\n const rePositionList = () => {\n if (!expanded || !optionListReference.current || !containerReference.current) {\n return;\n }\n\n // Check whether there is more space above or below the select\n // Check space between the bottom of select and top of viewport\n const spaceOnTopOfSelect = containerReference.current.getBoundingClientRect().bottom;\n\n // Check space between the top of the select and bottom of viewport\n const spaceOnBottomOfSelect =\n window.innerHeight - containerReference.current.getBoundingClientRect().top;\n\n // Set position as if there's more space on the bottom\n let position: Position = { top: \"2.75rem\", bottom: \"initial\" };\n\n // Set the position of the select\n if (spaceOnTopOfSelect > spaceOnBottomOfSelect) {\n position = { top: \"initial\", bottom: \"2.75rem\" };\n }\n\n setListPosition(position);\n\n // Calculate the potential max height of the options list\n calculateOptionListMaxHeight(position);\n };\n\n const calculateOptionListMaxHeight = (position: Position) => {\n // Calculate max height if there's more space below the select\n const listHeight = optionListReference.current?.getBoundingClientRect().height;\n const addNewButtonHeightWithMargin = addBtnRef.current\n ? addBtnRef.current.getBoundingClientRect().height +\n parseInt(getComputedStyle(addBtnRef.current).marginBottom)\n : 0;\n const transformOrigin = position.top !== \"initial\" ? \"top\" : \"bottom\";\n\n if (!containerReference.current) {\n console.error(\n \"The containerReference is empty for some reason in the SelectService.ts for the Select component in react-lib-components. We are trying to calculate the option list max height on expand\"\n );\n return;\n }\n\n const availableSpace =\n transformOrigin === \"top\"\n ? window.innerHeight - containerReference.current.getBoundingClientRect().bottom - 16\n : containerReference.current.getBoundingClientRect().top - 16;\n\n if (listHeight && availableSpace < listHeight + addNewButtonHeightWithMargin) {\n const maxHeightObject = {\n wrapper: `${availableSpace}px`,\n list:\n addNewButtonHeightWithMargin > 0\n ? `${availableSpace - addNewButtonHeightWithMargin}px`\n : \"none\"\n };\n setOptionsListMaxHeight(maxHeightObject);\n setOpacity(100);\n return;\n }\n\n setOptionsListMaxHeight({ wrapper: undefined, list: undefined });\n setOpacity(100);\n };\n\n return {\n optionsListMaxHeight,\n opacity,\n setOpacity,\n listPosition,\n setListPosition\n };\n};\n"],"names":["useArrowNavigation","expanded","setExpanded","isSearching","setIsSearching","setFocusedSelectItem","onOptionChangeHandler","childrenCount","setShouldClick","searchInputRef","addBtnRef","renderThreshold","onArrowNavigation","event","codesToPreventDefault","codesToPreventDefaultWhenSearching","isAddBtnFocused","current","document","activeElement","push","includes","code","metaKey","preventDefault","focus","prevState","target","_a","useSelectPositionList","optionListReference","containerReference","optionsListMaxHeight","setOptionsListMaxHeight","useState","wrapper","undefined","list","opacity","setOpacity","listPosition","setListPosition","useEffect","rePositionList","spaceOnTopOfSelect","getBoundingClientRect","bottom","spaceOnBottomOfSelect","window","innerHeight","top","position","calculateOptionListMaxHeight","listHeight","height","addNewButtonHeightWithMargin","parseInt","getComputedStyle","marginBottom","transformOrigin","console","error","availableSpace","maxHeightObject"],"mappings":"6FAwBO,MAAMA,EAAqB,EAChCC,WACAC,cACAC,cACAC,iBACAC,uBACAC,wBACAC,gBACAC,iBACAC,iBACAC,YACAC,sBAEA,MAAMC,EAAqBC,UACzB,MAAMC,EAAwB,CAC5B,YACA,UACA,YACA,aACA,QACA,SACA,MACA,QAGF,MAAMC,EAAqC,CACzC,YACA,UACA,QACA,SACA,WACA,aAGF,MAAMC,GAAkBN,UAAAA,SAAS,OAAA,EAATA,EAAWO,WAAYC,SAASC,cAExD,GAAIlB,EACFa,EAAsBM,KAAK,OAG7B,GAAIV,EACFK,EAAmCK,KAAK,OAG1C,GAAIN,EAAsBO,SAASR,EAAMS,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,IAAM,GAE/D,GAAIG,GAAcS,EAAiBT,EAAaE,EAA8B,CAC5E,MAAMQ,EAAkB,CACtB5B,QAAS,GAAG2B,MACZzB,KACEkB,EAA+B,EAC3B,GAAGO,EAAiBP,MACpB,QAERtB,EAAwB8B,GACxBxB,EAAW,KACX,MACD,CAEDN,EAAwB,CAAEE,aAASC,EAAWC,UAAMD,IACpDG,EAAW,IAAI,EAGjB,MAAO,CACLP,uBACAM,UACAC,aACAC,eACAC,kBACD"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});var e=require("react");var r=require("../Input/Input.cjs.js");function o(e){return e&&typeof e==="object"&&"default"in e?e:{default:e}}var s=o(e);const l=({search:o,optionsCount:l,searchPlaceholder:n,searchInputProps:t,searchInputClassName:u,expanded:a,setFocusedSelectItem:d})=>{var i,c;const[v,p]=e.useState("");const[h,f]=e.useState(false);const I=10;const P=e.useRef(null);const m=(i=o===null||o===void 0?void 0:o.renderThreshold)!==null&&i!==void 0?i:I;const S=l>=m;const b=e=>{p(e.currentTarget.value)};const y=()=>{if(o===null||o===void 0?void 0:o.enabled)return S;if(o)return o.enabled;return l>I};const N=()=>{var e,l,d,i,c,v,p;return s["default"].createElement(r.Input,{...(l=(e=o===null||o===void 0?void 0:o.searchInputProps)!==null&&e!==void 0?e:t)!==null&&l!==void 0?l:{},ref:P,onFocus:()=>f(true),onBlur:()=>f(false),onChange:b,className:u,wrapperProps:{className:(c=(i=(d=o===null||o===void 0?void 0:o.searchInputProps)===null||d===void 0?void 0:d.wrapperProps)===null||i===void 0?void 0:i.className)!==null&&c!==void 0?c:(v=t===null||t===void 0?void 0:t.wrapperProps)===null||v===void 0?void 0:v.className},style:{display:a?"block":"none"},type:"text",name:"search-option",placeholder:(p=o===null||o===void 0?void 0:o.searchPlaceholder)!==null&&p!==void 0?p:n})};const g=()=>{p("");f(false);d(-1)};const j=y();e.useEffect((()=>{var e;(((e=o===null||o===void 0?void 0:o.searchInputProps)===null||e===void 0?void 0:e.reset)||(t===null||t===void 0?void 0:t.reset))&&g()}),[t===null||t===void 0?void 0:t.reset,(c=o===null||o===void 0?void 0:o.searchInputProps)===null||c===void 0?void 0:c.reset]);e.useEffect((()=>{const e=!j&&!h;if(e)g()}),[h,j]);return{renderSearch:N,setIsSearching:f,searchVisible:j,searchThreshold:m,searchInputRef:P,filter:v,isSearching:h}};exports.useSearch=l;
2
- //# sourceMappingURL=useSearch.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSearch.cjs.js","sources":["../../../../../../src/components/Form/Select/useSearch.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { PartialInputProps, SearchProps } from \"./Select.interfaces\";\nimport { Input } from \"../Input/Input\";\n\ninterface Props {\n search?: SearchProps;\n optionsCount: number;\n /**\n * @deprecated\n */\n searchPlaceholder?: string;\n /**\n * @deprecated\n */\n searchInputProps?: PartialInputProps & { reset?: boolean };\n searchInputClassName: string;\n expanded: boolean;\n setFocusedSelectItem: (idx: number) => void;\n}\n\nexport const useSearch = ({\n search,\n optionsCount,\n searchPlaceholder,\n searchInputProps,\n searchInputClassName,\n expanded,\n setFocusedSelectItem\n}: Props) => {\n const [filter, setFilter] = useState(\"\");\n const [isSearching, setIsSearching] = useState(false);\n\n const DEFAULT_RENDER_THRESHOLD = 10;\n\n const searchInputRef = useRef<HTMLInputElement>(null);\n\n const threshold = search?.renderThreshold ?? DEFAULT_RENDER_THRESHOLD;\n const hasEnoughChildren = optionsCount >= threshold;\n\n const filterResults = (event: React.ChangeEvent<HTMLInputElement>) => {\n setFilter(event.currentTarget.value);\n };\n\n const shouldRenderSearch = () => {\n if (search?.enabled) {\n return hasEnoughChildren;\n }\n\n if (search) {\n return search.enabled as boolean;\n }\n\n return optionsCount > DEFAULT_RENDER_THRESHOLD;\n };\n\n const renderSearch = () => (\n <Input\n {...(search?.searchInputProps ?? searchInputProps ?? {})}\n ref={searchInputRef}\n onFocus={() => setIsSearching(true)}\n onBlur={() => setIsSearching(false)}\n onChange={filterResults}\n className={searchInputClassName}\n wrapperProps={{\n className:\n search?.searchInputProps?.wrapperProps?.className ??\n searchInputProps?.wrapperProps?.className\n }}\n style={{\n display: expanded ? \"block\" : \"none\"\n }}\n type=\"text\"\n name=\"search-option\"\n placeholder={search?.searchPlaceholder ?? searchPlaceholder}\n />\n );\n\n const resetSearchState = () => {\n setFilter(\"\");\n setIsSearching(false);\n setFocusedSelectItem(-1);\n };\n\n const visible = shouldRenderSearch();\n\n useEffect(() => {\n (search?.searchInputProps?.reset || searchInputProps?.reset) && resetSearchState();\n }, [searchInputProps?.reset, search?.searchInputProps?.reset]);\n\n useEffect(() => {\n const searchDeactivated =\n !visible &&\n !isSearching; /*solves issue in MultiSelect when we filtered result and selected result causes list to be shorter than threshold so still we have a filter applied but can't change it due to `visible` variable has false */\n if (searchDeactivated) {\n resetSearchState();\n }\n }, [isSearching, visible]);\n\n return {\n renderSearch,\n setIsSearching,\n searchVisible: visible,\n searchThreshold: threshold,\n searchInputRef,\n filter,\n isSearching\n };\n};\n"],"names":["useSearch","search","optionsCount","searchPlaceholder","searchInputProps","searchInputClassName","expanded","setFocusedSelectItem","filter","setFilter","useState","isSearching","setIsSearching","DEFAULT_RENDER_THRESHOLD","searchInputRef","useRef","threshold","_a","renderThreshold","hasEnoughChildren","filterResults","event","currentTarget","value","shouldRenderSearch","enabled","renderSearch","React","createElement","Input","_b","ref","onFocus","onBlur","onChange","className","wrapperProps","_e","_d","_c","_f","style","display","type","name","place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QAAU,QAEhCqC,KAAK,OACLC,KAAK,gBACLC,aAAaC,EAAA7C,IAAA,MAAAA,kBAAAA,EAAQE,qBAAqB,MAAA2C,SAAA,EAAAA,EAAA3C,GAE7C,EAED,MAAM4C,EAAmB,KACvBtC,EAAU,IACVG,EAAe,OACfL,GAAsB,EAAE,EAG1B,MAAMyC,EAAUxB,IAEhByB,EAAAA,WAAU,cACPhC,EAAAhB,IAAA,MAAAA,kBAAAA,EAAQG,oBAAgB,MAAAa,SAAA,OAAA,EAAAA,EAAEiC,SAAS9C,IAAA,MAAAA,SAAA,OAAA,EAAAA,EAAkB8C,SAAUH,GAAkB,GACjF,CAAC3C,IAAgB,MAAhBA,SAAA,OAAA,EAAAA,EAAkB8C,OAAOpB,EAAA7B,IAAA,MAAAA,kBAAAA,EAAQG,oBAAkB,MAAA0B,SAAA,OAAA,EAAAA,EAAAoB,QAEvDD,EAAAA,WAAU,KACR,MAAME,GACHH,IACArC,EACH,GAAIwC,EACFJ,GACD,GACA,CAACpC,EAAaqC,IAEjB,MAAO,CACLtB,eACAd,iBACAwC,cAAeJ,EACfK,gBAAiBrC,EACjBF,iBACAN,SACAG,cACD"}
@@ -1,17 +0,0 @@
1
- import React from "react";
2
- import { Position, UseArrowNavigationParams, UseSelectPositionListParams } from "./Select.interfaces";
3
- /** @scope .*/
4
- export declare const useArrowNavigation: ({ expanded, setExpanded, isSearching, setIsSearching, setFocusedSelectItem, onOptionChangeHandler, childrenCount, setShouldClick, searchInputRef, addBtnRef, renderThreshold }: UseArrowNavigationParams) => {
5
- onArrowNavigation: (event: React.KeyboardEvent) => void;
6
- };
7
- /** @scope .*/
8
- export declare const useSelectPositionList: ({ expanded, optionListReference, addBtnRef, containerReference }: UseSelectPositionListParams) => {
9
- optionsListMaxHeight: {
10
- wrapper?: string | undefined;
11
- list?: string | undefined;
12
- };
13
- opacity: number;
14
- setOpacity: React.Dispatch<React.SetStateAction<number>>;
15
- listPosition: Partial<Position>;
16
- setListPosition: React.Dispatch<React.SetStateAction<Partial<Position>>>;
17
- };
@@ -1,2 +0,0 @@
1
- import e from"../../../node_modules/style-inject/dist/style-inject.es.esm.js";var i='/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.FileItem-modules_sr-only__OwtI4{clip:rect(0,0,0,0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.FileItem-modules_hidden__w5rVy{display:none}.FileItem-modules_slide-in__g2fUZ{animation:FileItem-modules_slide-in__g2fUZ .5s forwards}@media (prefers-reduced-motion:reduce){.FileItem-modules_slide-in__g2fUZ{animation-duration:.1ms}}.FileItem-modules_slide-out__-dBYM{animation:FileItem-modules_slide-out__-dBYM .5s forwards}@media (prefers-reduced-motion:reduce){.FileItem-modules_slide-out__-dBYM{animation-duration:.1ms}}@keyframes FileItem-modules_slide-in__g2fUZ{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes FileItem-modules_slide-out__-dBYM{0%{transform:translateY(0)}to{transform:translateY(100vh)}}.FileItem-modules_file-item-wrapper__r4sb5{background-color:var(--input-background-color);border-radius:var(--input-border-radius);padding:.5rem 1.25rem;transition-duration:.2s;transition-property:all;transition-timing-function:ease-in-out}@media (prefers-reduced-motion:reduce){.FileItem-modules_file-item-wrapper__r4sb5{transition-duration:.1ms}}.FileItem-modules_file-item-wrapper__r4sb5 [class*=icon]{font-size:1.25rem}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_progress-bar__kVAJi{background-color:var(--color-black10)}.FileItem-modules_file-item-wrapper__r4sb5 span[class*=bar--]{border-radius:var(--input-border-radius);height:1rem}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_file-name__twzQ4{align-items:center;display:flex;margin:0}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_file-name__twzQ4 .FileItem-modules_friendly-name__p3xgX{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_action-icon__ODWUg{color:var(--color-primary);cursor:pointer;margin-left:auto;padding-left:1.25rem}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_file-icon__TbFi8{margin-right:.5rem}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_file-subtitle__TmXvr,.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_progress-bar__kVAJi{display:block;margin:.3125rem 1.75rem;padding:0}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_error__Q1RuV,.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_retry__2Euk8{color:var(--error)}.FileItem-modules_file-item-wrapper__r4sb5 .FileItem-modules_readonly__Jxi46{color:var(--greyed-out)}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkZpbGVJdGVtLm1vZHVsZXMuc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7Ozs7RUFjRTtBQUNGOzs7Ozs7Ozs7Ozs7OztFQWNFLENBQ0YsaUNBT0Usa0JBQXNCLENBQ3RCLFFBQVMsQ0FMVCxVQUFXL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lsZS1pdGVtLXdyYXBwZXIgLnJlYWRvbmx5IHtcbiAgY29sb3I6IHZhcigtLWdyZXllZC1vdXQpO1xufSJdfQ== */';var l={"sr-only":"FileItem-modules_sr-only__OwtI4",hidden:"FileItem-modules_hidden__w5rVy","slide-in":"FileItem-modules_slide-in__g2fUZ","slide-out":"FileItem-modules_slide-out__-dBYM","file-item-wrapper":"FileItem-modules_file-item-wrapper__r4sb5","progress-bar":"FileItem-modules_progress-bar__kVAJi","file-name":"FileItem-modules_file-name__twzQ4","friendly-name":"FileItem-modules_friendly-name__p3xgX","action-icon":"FileItem-modules_action-icon__ODWUg","file-icon":"FileItem-modules_file-icon__TbFi8","file-subtitle":"FileItem-modules_file-subtitle__TmXvr",error:"FileItem-modules_error__Q1RuV",retry:"FileItem-modules_retry__2Euk8",readonly:"FileItem-modules_readonly__Jxi46"};e(i);export{l as default};
2
- //# sourceMappingURL=FileItem.modules.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileItem.modules.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import{useState as e,useEffect as t}from"react";const r=({expanded:e,setExpanded:t,isSearching:r,setIsSearching:n,setFocusedSelectItem:o,onOptionChangeHandler:i,childrenCount:c,setShouldClick:s,searchInputRef:a,addBtnRef:u,renderThreshold:l})=>{const d=d=>{var p;const f=["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Space","Escape","End","Home"];const g=["ArrowDown","ArrowUp","Enter","Escape","MetaLeft","MetaRight"];const h=(u===null||u===void 0?void 0:u.current)===document.activeElement;if(e)f.push("Tab");if(u)g.push("Tab");if(f.includes(d.code)&&!d.metaKey&&!r)d.preventDefault();if(r&&g.includes(d.code))d.preventDefault();if(r)switch(d.code){case"ArrowDown":case"Enter":n(false);o(0);return;case"ArrowUp":n(false);o(c-1);return;case"Escape":n(false);t(false);return;case"Tab":if(u===null||u===void 0?void 0:u.current){u.current.focus();return}n(false);t(false)}else switch(d.code){case"ArrowDown":if(!e){t(true);o(0);return}o((e=>e+1>c-1?0:e+1));return;case"ArrowUp":if(!e){t(true);o(c-1);return}o((e=>e-1<0?c-1:e-1));return;case"Space":if(!e){t(true);o(0);return}i(d.target);s(true);t(false);return;case"Enter":case"Home":o(0);return;case"Tab":if(c>=l&&e&&!h){n(true);(p=a.current)===null||p===void 0?void 0:p.focus();return}else if((u===null||u===void 0?void 0:u.current)&&e&&!h){u.current.focus();return}t(false);return;case"Escape":if(e)t(false);return;case"End":o(c-1);return;case"ArrowLeft":if(d.metaKey&&e){d.preventDefault();o(0)}return;case"ArrowRight":if(d.metaKey&&e){d.preventDefault();o(c-1)}return}};return{onArrowNavigation:d}};const n=({expanded:r,optionListReference:n,addBtnRef:o,containerReference:i})=>{const[c,s]=e({wrapper:void 0,list:void 0});const[a,u]=e(0);const[l,d]=e({});t((()=>{p()}),[r]);const p=()=>{if(!r||!n.current||!i.current)return;const e=i.current.getBoundingClientRect().bottom;const t=window.innerHeight-i.current.getBoundingClientRect().top;let o={top:"2.75rem",bottom:"initial"};if(e>t)o={top:"initial",bottom:"2.75rem"};d(o);f(o)};const f=e=>{var t;const r=(t=n.current)===null||t===void 0?void 0:t.getBoundingClientRect().height;const c=o.current?o.current.getBoundingClientRect().height+parseInt(getComputedStyle(o.current).marginBottom):0;const a=e.top!=="initial"?"top":"bottom";if(!i.current){console.error("The containerReference is empty for some reason in the SelectService.ts for the Select component in react-lib-components. We are trying to calculate the option list max height on expand");return}const l=a==="top"?window.innerHeight-i.current.getBoundingClientRect().bottom-16:i.current.getBoundingClientRect().top-16;if(r&&l<r+c){const e={wrapper:`${l}px`,list:c>0?`${l-c}px`:"none"};s(e);u(100);return}s({wrapper:void 0,list:void 0});u(100)};return{optionsListMaxHeight:c,opacity:a,setOpacity:u,listPosition:l,setListPosition:d}};export{r as useArrowNavigation,n as useSelectPositionList};
2
- //# sourceMappingURL=SelectService.esm.js.map