@workday/canvas-kit-react 10.0.0-alpha.540-next.0 → 10.0.0-alpha.546-next.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 (219) hide show
  1. package/collection/index.ts +1 -0
  2. package/collection/lib/useBaseListModel.tsx +3 -3
  3. package/collection/lib/useListItemRegister.tsx +1 -1
  4. package/collection/lib/useListRenderItem.tsx +2 -2
  5. package/combobox/index.ts +11 -4
  6. package/combobox/lib/Combobox.tsx +1 -1
  7. package/combobox/lib/ComboboxCard.tsx +1 -1
  8. package/combobox/lib/ComboboxInput.tsx +2 -90
  9. package/combobox/lib/ComboboxMenu.tsx +4 -3
  10. package/combobox/lib/ComboboxMenuItem.tsx +9 -8
  11. package/combobox/lib/ComboboxMenuList.tsx +1 -1
  12. package/combobox/lib/ComboboxPopper.tsx +20 -0
  13. package/combobox/lib/hooks/index.ts +9 -0
  14. package/combobox/lib/hooks/useComboboxInput.ts +88 -0
  15. package/combobox/lib/hooks/useComboboxKeyboardTypeAhead.ts +127 -0
  16. package/combobox/lib/hooks/useComboboxListKeyboardHandler.ts +23 -0
  17. package/combobox/lib/{useComboboxModel.tsx → hooks/useComboboxModel.tsx} +6 -2
  18. package/combobox/lib/hooks/useComboboxMoveCursorToSelected.tsx +27 -0
  19. package/combobox/lib/hooks/useComboboxResetCursorToSelected.tsx +18 -0
  20. package/combobox/lib/hooks/useSetPopupWidth.ts +16 -0
  21. package/common/lib/utils/components.ts +284 -274
  22. package/common/lib/utils/models.ts +67 -84
  23. package/dist/commonjs/collection/index.d.ts +1 -0
  24. package/dist/commonjs/collection/index.d.ts.map +1 -1
  25. package/dist/commonjs/collection/index.js +3 -1
  26. package/dist/commonjs/collection/lib/useBaseListModel.d.ts +1 -1
  27. package/dist/commonjs/collection/lib/useBaseListModel.d.ts.map +1 -1
  28. package/dist/commonjs/collection/lib/useBaseListModel.js +2 -2
  29. package/dist/commonjs/collection/lib/useListItemRegister.js +2 -2
  30. package/dist/commonjs/collection/lib/useListRenderItem.js +2 -2
  31. package/dist/commonjs/combobox/index.d.ts +1 -4
  32. package/dist/commonjs/combobox/index.d.ts.map +1 -1
  33. package/dist/commonjs/combobox/index.js +11 -9
  34. package/dist/commonjs/combobox/lib/Combobox.d.ts +9 -3
  35. package/dist/commonjs/combobox/lib/Combobox.d.ts.map +1 -1
  36. package/dist/commonjs/combobox/lib/Combobox.js +2 -2
  37. package/dist/commonjs/combobox/lib/ComboboxCard.js +3 -3
  38. package/dist/commonjs/combobox/lib/ComboboxInput.d.ts +1 -106
  39. package/dist/commonjs/combobox/lib/ComboboxInput.d.ts.map +1 -1
  40. package/dist/commonjs/combobox/lib/ComboboxInput.js +4 -71
  41. package/dist/commonjs/combobox/lib/ComboboxMenu.d.ts +9 -3
  42. package/dist/commonjs/combobox/lib/ComboboxMenu.d.ts.map +1 -1
  43. package/dist/commonjs/combobox/lib/ComboboxMenu.js +5 -4
  44. package/dist/commonjs/combobox/lib/ComboboxMenuItem.d.ts +7 -1
  45. package/dist/commonjs/combobox/lib/ComboboxMenuItem.d.ts.map +1 -1
  46. package/dist/commonjs/combobox/lib/ComboboxMenuItem.js +7 -7
  47. package/dist/commonjs/combobox/lib/ComboboxMenuList.js +2 -2
  48. package/dist/commonjs/combobox/lib/ComboboxPopper.d.ts +97 -0
  49. package/dist/commonjs/combobox/lib/ComboboxPopper.d.ts.map +1 -0
  50. package/dist/commonjs/{select/lib/SelectOption.js → combobox/lib/ComboboxPopper.js} +12 -8
  51. package/dist/commonjs/combobox/lib/hooks/index.d.ts +10 -0
  52. package/dist/commonjs/combobox/lib/hooks/index.d.ts.map +1 -0
  53. package/dist/commonjs/combobox/lib/hooks/index.js +21 -0
  54. package/dist/commonjs/combobox/lib/hooks/useComboboxInput.d.ts +107 -0
  55. package/dist/commonjs/combobox/lib/hooks/useComboboxInput.d.ts.map +1 -0
  56. package/dist/commonjs/combobox/lib/hooks/useComboboxInput.js +74 -0
  57. package/dist/{es6/combobox/lib → commonjs/combobox/lib/hooks}/useComboboxInputOpenWithArrowKeys.d.ts +6 -6
  58. package/dist/commonjs/combobox/lib/hooks/useComboboxInputOpenWithArrowKeys.d.ts.map +1 -0
  59. package/dist/commonjs/combobox/lib/hooks/useComboboxKeyboardTypeAhead.d.ts +101 -0
  60. package/dist/commonjs/combobox/lib/hooks/useComboboxKeyboardTypeAhead.d.ts.map +1 -0
  61. package/dist/commonjs/combobox/lib/hooks/useComboboxKeyboardTypeAhead.js +109 -0
  62. package/dist/commonjs/combobox/lib/hooks/useComboboxListKeyboardHandler.d.ts +84 -0
  63. package/dist/commonjs/combobox/lib/hooks/useComboboxListKeyboardHandler.d.ts.map +1 -0
  64. package/dist/commonjs/combobox/lib/hooks/useComboboxListKeyboardHandler.js +22 -0
  65. package/dist/commonjs/combobox/lib/hooks/useComboboxLoader.d.ts.map +1 -0
  66. package/dist/commonjs/combobox/lib/{useComboboxModel.d.ts → hooks/useComboboxModel.d.ts} +196 -196
  67. package/dist/commonjs/combobox/lib/hooks/useComboboxModel.d.ts.map +1 -0
  68. package/dist/commonjs/combobox/lib/{useComboboxModel.js → hooks/useComboboxModel.js} +3 -2
  69. package/dist/commonjs/combobox/lib/hooks/useComboboxMoveCursorToSelected.d.ts +82 -0
  70. package/dist/commonjs/combobox/lib/hooks/useComboboxMoveCursorToSelected.d.ts.map +1 -0
  71. package/dist/commonjs/combobox/lib/hooks/useComboboxMoveCursorToSelected.js +33 -0
  72. package/dist/commonjs/combobox/lib/hooks/useComboboxResetCursorToSelected.d.ts +82 -0
  73. package/dist/commonjs/combobox/lib/hooks/useComboboxResetCursorToSelected.d.ts.map +1 -0
  74. package/dist/commonjs/combobox/lib/hooks/useComboboxResetCursorToSelected.js +23 -0
  75. package/dist/commonjs/combobox/lib/hooks/useSetPopupWidth.d.ts +82 -0
  76. package/dist/commonjs/combobox/lib/hooks/useSetPopupWidth.d.ts.map +1 -0
  77. package/dist/commonjs/combobox/lib/hooks/useSetPopupWidth.js +22 -0
  78. package/dist/commonjs/common/lib/utils/components.d.ts.map +1 -1
  79. package/dist/commonjs/common/lib/utils/models.d.ts +4 -4
  80. package/dist/commonjs/common/lib/utils/models.d.ts.map +1 -1
  81. package/dist/commonjs/common/lib/utils/models.js +7 -8
  82. package/dist/commonjs/form-field/lib/FormField.d.ts.map +1 -1
  83. package/dist/commonjs/form-field/lib/FormField.js +3 -2
  84. package/dist/commonjs/menu/lib/MenuPopper.d.ts.map +1 -1
  85. package/dist/commonjs/menu/lib/MenuPopper.js +10 -1
  86. package/dist/commonjs/popup/lib/PopupPopper.d.ts.map +1 -1
  87. package/dist/commonjs/popup/lib/PopupPopper.js +10 -1
  88. package/dist/commonjs/select/index.d.ts +1 -1
  89. package/dist/commonjs/select/index.d.ts.map +1 -1
  90. package/dist/commonjs/select/index.js +1 -1
  91. package/dist/commonjs/select/lib/Select.d.ts +2634 -18
  92. package/dist/commonjs/select/lib/Select.d.ts.map +1 -1
  93. package/dist/commonjs/select/lib/Select.js +141 -84
  94. package/dist/commonjs/select/lib/hooks/index.d.ts +4 -0
  95. package/dist/commonjs/select/lib/hooks/index.d.ts.map +1 -0
  96. package/dist/commonjs/select/lib/hooks/index.js +15 -0
  97. package/dist/commonjs/select/lib/hooks/useSelectCard.d.ts +83 -0
  98. package/dist/commonjs/select/lib/hooks/useSelectCard.d.ts.map +1 -0
  99. package/dist/commonjs/select/lib/hooks/useSelectCard.js +13 -0
  100. package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts +112 -0
  101. package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts.map +1 -0
  102. package/dist/commonjs/select/lib/hooks/useSelectInput.js +49 -0
  103. package/dist/commonjs/select/lib/hooks/useSelectModel.d.ts +1779 -0
  104. package/dist/commonjs/select/lib/hooks/useSelectModel.d.ts.map +1 -0
  105. package/dist/commonjs/select/lib/hooks/useSelectModel.js +32 -0
  106. package/dist/es6/collection/index.d.ts +1 -0
  107. package/dist/es6/collection/index.d.ts.map +1 -1
  108. package/dist/es6/collection/index.js +1 -0
  109. package/dist/es6/collection/lib/useBaseListModel.d.ts +1 -1
  110. package/dist/es6/collection/lib/useBaseListModel.d.ts.map +1 -1
  111. package/dist/es6/collection/lib/useBaseListModel.js +2 -2
  112. package/dist/es6/collection/lib/useListItemRegister.js +2 -2
  113. package/dist/es6/collection/lib/useListRenderItem.js +2 -2
  114. package/dist/es6/combobox/index.d.ts +1 -4
  115. package/dist/es6/combobox/index.d.ts.map +1 -1
  116. package/dist/es6/combobox/index.js +1 -4
  117. package/dist/es6/combobox/lib/Combobox.d.ts +9 -3
  118. package/dist/es6/combobox/lib/Combobox.d.ts.map +1 -1
  119. package/dist/es6/combobox/lib/Combobox.js +1 -1
  120. package/dist/es6/combobox/lib/ComboboxCard.js +1 -1
  121. package/dist/es6/combobox/lib/ComboboxInput.d.ts +1 -106
  122. package/dist/es6/combobox/lib/ComboboxInput.d.ts.map +1 -1
  123. package/dist/es6/combobox/lib/ComboboxInput.js +2 -69
  124. package/dist/es6/combobox/lib/ComboboxMenu.d.ts +9 -3
  125. package/dist/es6/combobox/lib/ComboboxMenu.d.ts.map +1 -1
  126. package/dist/es6/combobox/lib/ComboboxMenu.js +4 -3
  127. package/dist/es6/combobox/lib/ComboboxMenuItem.d.ts +7 -1
  128. package/dist/es6/combobox/lib/ComboboxMenuItem.d.ts.map +1 -1
  129. package/dist/es6/combobox/lib/ComboboxMenuItem.js +7 -7
  130. package/dist/es6/combobox/lib/ComboboxMenuList.js +1 -1
  131. package/dist/es6/combobox/lib/ComboboxPopper.d.ts +97 -0
  132. package/dist/es6/combobox/lib/ComboboxPopper.d.ts.map +1 -0
  133. package/dist/es6/combobox/lib/ComboboxPopper.js +12 -0
  134. package/dist/es6/combobox/lib/hooks/index.d.ts +10 -0
  135. package/dist/es6/combobox/lib/hooks/index.d.ts.map +1 -0
  136. package/dist/es6/combobox/lib/hooks/index.js +9 -0
  137. package/dist/es6/combobox/lib/hooks/useComboboxInput.d.ts +107 -0
  138. package/dist/es6/combobox/lib/hooks/useComboboxInput.d.ts.map +1 -0
  139. package/dist/es6/combobox/lib/hooks/useComboboxInput.js +68 -0
  140. package/dist/{commonjs/combobox/lib → es6/combobox/lib/hooks}/useComboboxInputOpenWithArrowKeys.d.ts +6 -6
  141. package/dist/es6/combobox/lib/hooks/useComboboxInputOpenWithArrowKeys.d.ts.map +1 -0
  142. package/dist/es6/combobox/lib/hooks/useComboboxKeyboardTypeAhead.d.ts +101 -0
  143. package/dist/es6/combobox/lib/hooks/useComboboxKeyboardTypeAhead.d.ts.map +1 -0
  144. package/dist/es6/combobox/lib/hooks/useComboboxKeyboardTypeAhead.js +103 -0
  145. package/dist/es6/combobox/lib/hooks/useComboboxListKeyboardHandler.d.ts +84 -0
  146. package/dist/es6/combobox/lib/hooks/useComboboxListKeyboardHandler.d.ts.map +1 -0
  147. package/dist/es6/combobox/lib/hooks/useComboboxListKeyboardHandler.js +19 -0
  148. package/dist/es6/combobox/lib/hooks/useComboboxLoader.d.ts.map +1 -0
  149. package/dist/es6/combobox/lib/{useComboboxModel.d.ts → hooks/useComboboxModel.d.ts} +196 -196
  150. package/dist/es6/combobox/lib/hooks/useComboboxModel.d.ts.map +1 -0
  151. package/dist/es6/combobox/lib/{useComboboxModel.js → hooks/useComboboxModel.js} +3 -2
  152. package/dist/es6/combobox/lib/hooks/useComboboxMoveCursorToSelected.d.ts +82 -0
  153. package/dist/es6/combobox/lib/hooks/useComboboxMoveCursorToSelected.d.ts.map +1 -0
  154. package/dist/es6/combobox/lib/hooks/useComboboxMoveCursorToSelected.js +27 -0
  155. package/dist/es6/combobox/lib/hooks/useComboboxResetCursorToSelected.d.ts +82 -0
  156. package/dist/es6/combobox/lib/hooks/useComboboxResetCursorToSelected.d.ts.map +1 -0
  157. package/dist/es6/combobox/lib/hooks/useComboboxResetCursorToSelected.js +17 -0
  158. package/dist/es6/combobox/lib/hooks/useSetPopupWidth.d.ts +82 -0
  159. package/dist/es6/combobox/lib/hooks/useSetPopupWidth.d.ts.map +1 -0
  160. package/dist/es6/combobox/lib/hooks/useSetPopupWidth.js +16 -0
  161. package/dist/es6/common/lib/utils/components.d.ts.map +1 -1
  162. package/dist/es6/common/lib/utils/models.d.ts +4 -4
  163. package/dist/es6/common/lib/utils/models.d.ts.map +1 -1
  164. package/dist/es6/common/lib/utils/models.js +7 -8
  165. package/dist/es6/form-field/lib/FormField.d.ts.map +1 -1
  166. package/dist/es6/form-field/lib/FormField.js +3 -2
  167. package/dist/es6/menu/lib/MenuPopper.d.ts.map +1 -1
  168. package/dist/es6/menu/lib/MenuPopper.js +10 -1
  169. package/dist/es6/popup/lib/PopupPopper.d.ts.map +1 -1
  170. package/dist/es6/popup/lib/PopupPopper.js +10 -1
  171. package/dist/es6/select/index.d.ts +1 -1
  172. package/dist/es6/select/index.d.ts.map +1 -1
  173. package/dist/es6/select/index.js +1 -1
  174. package/dist/es6/select/lib/Select.d.ts +2634 -18
  175. package/dist/es6/select/lib/Select.d.ts.map +1 -1
  176. package/dist/es6/select/lib/Select.js +139 -66
  177. package/dist/es6/select/lib/hooks/index.d.ts +4 -0
  178. package/dist/es6/select/lib/hooks/index.d.ts.map +1 -0
  179. package/dist/es6/select/lib/hooks/index.js +3 -0
  180. package/dist/es6/select/lib/hooks/useSelectCard.d.ts +83 -0
  181. package/dist/es6/select/lib/hooks/useSelectCard.d.ts.map +1 -0
  182. package/dist/es6/select/lib/hooks/useSelectCard.js +10 -0
  183. package/dist/es6/select/lib/hooks/useSelectInput.d.ts +112 -0
  184. package/dist/es6/select/lib/hooks/useSelectInput.d.ts.map +1 -0
  185. package/dist/es6/select/lib/hooks/useSelectInput.js +46 -0
  186. package/dist/es6/select/lib/hooks/useSelectModel.d.ts +1779 -0
  187. package/dist/es6/select/lib/hooks/useSelectModel.d.ts.map +1 -0
  188. package/dist/es6/select/lib/hooks/useSelectModel.js +29 -0
  189. package/form-field/lib/FormField.tsx +8 -2
  190. package/menu/lib/MenuPopper.tsx +14 -1
  191. package/package.json +4 -4
  192. package/popup/lib/Popper.tsx +1 -1
  193. package/popup/lib/PopupPopper.tsx +17 -1
  194. package/select/index.ts +1 -1
  195. package/select/lib/Select.tsx +175 -111
  196. package/select/lib/hooks/index.ts +3 -0
  197. package/select/lib/hooks/useSelectCard.ts +11 -0
  198. package/select/lib/hooks/useSelectInput.ts +74 -0
  199. package/select/lib/hooks/useSelectModel.tsx +30 -0
  200. package/dist/commonjs/combobox/lib/useComboboxInputOpenWithArrowKeys.d.ts.map +0 -1
  201. package/dist/commonjs/combobox/lib/useComboboxLoader.d.ts.map +0 -1
  202. package/dist/commonjs/combobox/lib/useComboboxModel.d.ts.map +0 -1
  203. package/dist/commonjs/select/lib/SelectOption.d.ts +0 -20
  204. package/dist/commonjs/select/lib/SelectOption.d.ts.map +0 -1
  205. package/dist/es6/combobox/lib/useComboboxInputOpenWithArrowKeys.d.ts.map +0 -1
  206. package/dist/es6/combobox/lib/useComboboxLoader.d.ts.map +0 -1
  207. package/dist/es6/combobox/lib/useComboboxModel.d.ts.map +0 -1
  208. package/dist/es6/select/lib/SelectOption.d.ts +0 -20
  209. package/dist/es6/select/lib/SelectOption.d.ts.map +0 -1
  210. package/dist/es6/select/lib/SelectOption.js +0 -7
  211. package/select/lib/SelectOption.tsx +0 -33
  212. /package/combobox/lib/{useComboboxInputOpenWithArrowKeys.ts → hooks/useComboboxInputOpenWithArrowKeys.ts} +0 -0
  213. /package/combobox/lib/{useComboboxLoader.ts → hooks/useComboboxLoader.ts} +0 -0
  214. /package/dist/commonjs/combobox/lib/{useComboboxInputOpenWithArrowKeys.js → hooks/useComboboxInputOpenWithArrowKeys.js} +0 -0
  215. /package/dist/commonjs/combobox/lib/{useComboboxLoader.d.ts → hooks/useComboboxLoader.d.ts} +0 -0
  216. /package/dist/commonjs/combobox/lib/{useComboboxLoader.js → hooks/useComboboxLoader.js} +0 -0
  217. /package/dist/es6/combobox/lib/{useComboboxInputOpenWithArrowKeys.js → hooks/useComboboxInputOpenWithArrowKeys.js} +0 -0
  218. /package/dist/es6/combobox/lib/{useComboboxLoader.d.ts → hooks/useComboboxLoader.d.ts} +0 -0
  219. /package/dist/es6/combobox/lib/{useComboboxLoader.js → hooks/useComboboxLoader.js} +0 -0
@@ -0,0 +1,97 @@
1
+ import * as React from 'react';
2
+ export declare const useMenuPopper: import("@workday/canvas-kit-react/common").BehaviorHook<{
3
+ state: {
4
+ stackRef: React.RefObject<HTMLDivElement>;
5
+ targetRef: React.RefObject<HTMLButtonElement>;
6
+ initialFocusRef: React.RefObject<any> | undefined;
7
+ returnFocusRef: React.RefObject<any> | undefined;
8
+ placement: import("@popperjs/core").Placement;
9
+ id: string;
10
+ visibility: "hidden" | "visible";
11
+ };
12
+ events: {
13
+ updatePlacement(data: {
14
+ placement: import("@popperjs/core").Placement;
15
+ }): void;
16
+ show(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
17
+ hide(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
18
+ };
19
+ }, {
20
+ open: boolean;
21
+ anchorElement: React.RefObject<HTMLButtonElement>;
22
+ ref: (instance: unknown) => void;
23
+ onPlacementChange: (placement: import("@popperjs/core").Placement) => void;
24
+ }>;
25
+ export declare const ComboboxMenuPopper: import("@workday/canvas-kit-react/common").ElementComponentM<"div", import("@workday/canvas-kit-react/popup").PopperProps & React.RefAttributes<HTMLDivElement>, {
26
+ state: {
27
+ stackRef: React.RefObject<HTMLDivElement>;
28
+ targetRef: React.RefObject<HTMLButtonElement>;
29
+ initialFocusRef: React.RefObject<any> | undefined;
30
+ returnFocusRef: React.RefObject<any> | undefined;
31
+ placement: import("@popperjs/core").Placement;
32
+ id: string;
33
+ visibility: "hidden" | "visible";
34
+ selectedIds: string[] | "all";
35
+ unselectedIds: string[];
36
+ cursorId: string;
37
+ columnCount: number;
38
+ pageSizeRef: React.MutableRefObject<number>;
39
+ cursorIndexRef: {
40
+ readonly current: number;
41
+ };
42
+ UNSTABLE_virtual: {
43
+ virtualItems: import("../../collection/lib/react-virtual").VirtualItem[];
44
+ totalSize: number;
45
+ scrollToOffset: (index: number, options?: import("../../collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
46
+ scrollToIndex: (index: number, options?: import("../../collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
47
+ measure: () => void;
48
+ };
49
+ UNSTABLE_defaultItemHeight: number;
50
+ containerRef: React.RefObject<HTMLDivElement>;
51
+ orientation: "horizontal" | "vertical";
52
+ indexRef: React.MutableRefObject<number>;
53
+ nonInteractiveIds: string[];
54
+ isVirtualized: boolean;
55
+ items: import("../..").Item<any>[];
56
+ mode: "multiple" | "single";
57
+ };
58
+ events: {
59
+ updatePlacement(data: {
60
+ placement: import("@popperjs/core").Placement;
61
+ }): void;
62
+ show(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
63
+ hide(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
64
+ select(data: {
65
+ id: string;
66
+ }): void;
67
+ selectAll(): void;
68
+ unselectAll(): void;
69
+ goTo(data: {
70
+ id: string;
71
+ }): void;
72
+ goToNext(): void;
73
+ goToPrevious(): void;
74
+ goToPreviousRow(): void;
75
+ goToNextRow(): void;
76
+ goToFirst(): void;
77
+ goToLast(): void;
78
+ goToFirstOfRow(): void;
79
+ goToLastOfRow(): void;
80
+ goToNextPage(): void;
81
+ goToPreviousPage(): void;
82
+ registerItem(data: {
83
+ item: any;
84
+ textValue: string;
85
+ }): void;
86
+ unregisterItem(data: {
87
+ id: string;
88
+ }): void;
89
+ updateItemHeight(data: {
90
+ value: number;
91
+ }): void;
92
+ };
93
+ selection: import("../../collection/lib/useSelectionListModel").SelectionManager;
94
+ navigation: import("../../collection/lib/useCursorListModel").NavigationManager;
95
+ getId: (item: any) => string;
96
+ }>;
97
+ //# sourceMappingURL=ComboboxPopper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboboxPopper.d.ts","sourceRoot":"","sources":["../../../../combobox/lib/ComboboxPopper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;EAAiB,CAAC;AAE5C,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU7B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { createSubcomponent } from '@workday/canvas-kit-react/common';
3
+ import { usePopupPopper } from '@workday/canvas-kit-react/popup';
4
+ import { Menu, useMenuModel } from '@workday/canvas-kit-react/menu';
5
+ export const useMenuPopper = usePopupPopper;
6
+ export const ComboboxMenuPopper = createSubcomponent('div')({
7
+ displayName: 'Combobox.Menu.Popper',
8
+ modelHook: useMenuModel,
9
+ elemPropsHook: useMenuPopper,
10
+ })(({ children, ...elemProps }) => {
11
+ return (React.createElement(Menu.Popper, Object.assign({ fallbackPlacements: ['top', 'bottom'] }, elemProps), children));
12
+ });
@@ -0,0 +1,10 @@
1
+ export * from './useComboboxInputOpenWithArrowKeys';
2
+ export * from './useComboboxLoader';
3
+ export * from './useComboboxModel';
4
+ export * from './useComboboxMoveCursorToSelected';
5
+ export * from './useSetPopupWidth';
6
+ export * from './useComboboxKeyboardTypeAhead';
7
+ export * from './useComboboxListKeyboardHandler';
8
+ export * from './useComboboxInput';
9
+ export * from './useComboboxResetCursorToSelected';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../combobox/lib/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,oCAAoC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './useComboboxInputOpenWithArrowKeys';
2
+ export * from './useComboboxLoader';
3
+ export * from './useComboboxModel';
4
+ export * from './useComboboxMoveCursorToSelected';
5
+ export * from './useSetPopupWidth';
6
+ export * from './useComboboxKeyboardTypeAhead';
7
+ export * from './useComboboxListKeyboardHandler';
8
+ export * from './useComboboxInput';
9
+ export * from './useComboboxResetCursorToSelected';
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ /**
3
+ * `useComboboxInput` Adds all attributes necessary to start with a {@link ComboboxInput Combobox.Input}. It opens the
4
+ * menu with arrow keys, uses {@link useListActiveDescendant}, and handles keyboard arrows to
5
+ * navigate items of the menu. You may also compose this hook to add more specific behaviors for
6
+ * your {@link ComboboxInput Combobox.Input}.
7
+ */
8
+ export declare const useComboboxInput: import("@workday/canvas-kit-react/common").BehaviorHook<{
9
+ state: {
10
+ stackRef: React.RefObject<HTMLDivElement>;
11
+ targetRef: React.RefObject<HTMLButtonElement>;
12
+ initialFocusRef: React.RefObject<any> | undefined;
13
+ returnFocusRef: React.RefObject<any> | undefined;
14
+ placement: import("@popperjs/core").Placement;
15
+ id: string;
16
+ visibility: "hidden" | "visible";
17
+ selectedIds: string[] | "all";
18
+ unselectedIds: string[];
19
+ cursorId: string;
20
+ columnCount: number;
21
+ pageSizeRef: React.MutableRefObject<number>;
22
+ cursorIndexRef: {
23
+ readonly current: number;
24
+ };
25
+ UNSTABLE_virtual: {
26
+ virtualItems: import("../../../collection/lib/react-virtual").VirtualItem[];
27
+ totalSize: number;
28
+ scrollToOffset: (index: number, options?: import("../../../collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
29
+ scrollToIndex: (index: number, options?: import("../../../collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
30
+ measure: () => void;
31
+ };
32
+ UNSTABLE_defaultItemHeight: number;
33
+ containerRef: React.RefObject<HTMLDivElement>;
34
+ orientation: "horizontal" | "vertical";
35
+ indexRef: React.MutableRefObject<number>;
36
+ nonInteractiveIds: string[];
37
+ isVirtualized: boolean;
38
+ items: import("@workday/canvas-kit-react/collection").Item<any>[];
39
+ mode: "multiple" | "single";
40
+ value: string | undefined;
41
+ inputRef: React.RefObject<HTMLInputElement>;
42
+ width: number;
43
+ };
44
+ events: {
45
+ setWidth(width: number): void;
46
+ updatePlacement(data: {
47
+ placement: import("@popperjs/core").Placement;
48
+ }): void;
49
+ show(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
50
+ hide(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
51
+ select(data: {
52
+ id: string;
53
+ }): void;
54
+ selectAll(): void;
55
+ unselectAll(): void;
56
+ goTo(data: {
57
+ id: string;
58
+ }): void;
59
+ goToNext(): void;
60
+ goToPrevious(): void;
61
+ goToPreviousRow(): void;
62
+ goToNextRow(): void;
63
+ goToFirst(): void;
64
+ goToLast(): void;
65
+ goToFirstOfRow(): void;
66
+ goToLastOfRow(): void;
67
+ goToNextPage(): void;
68
+ goToPreviousPage(): void;
69
+ registerItem(data: {
70
+ item: any;
71
+ textValue: string;
72
+ }): void;
73
+ unregisterItem(data: {
74
+ id: string;
75
+ }): void;
76
+ updateItemHeight(data: {
77
+ value: number;
78
+ }): void;
79
+ };
80
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
81
+ selection: import("../../../collection/lib/useSelectionListModel").SelectionManager;
82
+ navigation: import("../../../collection/lib/useCursorListModel").NavigationManager;
83
+ getId: (item: any) => string;
84
+ }, {
85
+ readonly onKeyDown: (event: React.KeyboardEvent) => void;
86
+ readonly onBlur: (event: React.FocusEvent) => void;
87
+ readonly onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
88
+ readonly onClick: (event: React.MouseEvent) => void;
89
+ readonly value: string | undefined;
90
+ readonly role: "combobox";
91
+ readonly 'aria-haspopup': true;
92
+ readonly 'aria-expanded': boolean;
93
+ readonly 'aria-autocomplete': "list";
94
+ readonly 'aria-controls': `${string}-list`;
95
+ readonly id: string;
96
+ readonly ref: (instance: unknown) => void;
97
+ } & {
98
+ onKeyDown(event: React.KeyboardEvent<Element>): void;
99
+ } & {
100
+ 'aria-activedescendant': string | undefined;
101
+ } & {
102
+ onKeyDown(event: React.KeyboardEvent<Element>): void;
103
+ } & {
104
+ ref: (instance: unknown) => void;
105
+ onClick: (event: React.MouseEvent<Element, MouseEvent>) => void;
106
+ }>;
107
+ //# sourceMappingURL=useComboboxInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComboboxInput.d.ts","sourceRoot":"","sources":["../../../../../combobox/lib/hooks/useComboboxInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA6BN,mBAAmB;6BActB,gBAAgB;;8BAIf,gBAAgB;;;;;;;;;;;;;;;;;;EAoBpC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { composeHooks, createElemPropsHook, useForkRef } from '@workday/canvas-kit-react/common';
3
+ import { usePopupTarget } from '@workday/canvas-kit-react/popup';
4
+ import { useListActiveDescendant } from '@workday/canvas-kit-react/collection';
5
+ import { useComboboxModel, useComboboxInputOpenWithArrowKeys, useSetPopupWidth, useComboboxListKeyboardHandler, } from './index';
6
+ /**
7
+ * `useComboboxInput` Adds all attributes necessary to start with a {@link ComboboxInput Combobox.Input}. It opens the
8
+ * menu with arrow keys, uses {@link useListActiveDescendant}, and handles keyboard arrows to
9
+ * navigate items of the menu. You may also compose this hook to add more specific behaviors for
10
+ * your {@link ComboboxInput Combobox.Input}.
11
+ */
12
+ export const useComboboxInput = composeHooks(createElemPropsHook(useComboboxModel)((model, ref) => {
13
+ const elementRef = useForkRef(ref, model.state.inputRef);
14
+ React.useEffect(() => {
15
+ var _a;
16
+ if (model.state.cursorId && model.state.visibility === 'visible') {
17
+ const item = model.navigation.getItem(model.state.cursorId, model);
18
+ if (model.state.isVirtualized && item) {
19
+ model.state.UNSTABLE_virtual.scrollToIndex(item.index);
20
+ }
21
+ else {
22
+ const listboxId = (_a = model.state.inputRef.current) === null || _a === void 0 ? void 0 : _a.getAttribute('aria-controls');
23
+ if (listboxId) {
24
+ const menuItem = document.querySelector(`[id="${listboxId}"] [data-id="${model.state.cursorId}"]`);
25
+ if (menuItem) {
26
+ requestAnimationFrame(() => {
27
+ menuItem.scrollIntoView({ block: 'nearest' });
28
+ });
29
+ }
30
+ }
31
+ }
32
+ }
33
+ // we only want to run this effect if the cursor, visibility and selectedIds change and not any other time
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ }, [model.state.cursorId, model.state.selectedIds, model.state.visibility]);
36
+ return {
37
+ onKeyDown(event) {
38
+ if (event.key === 'Enter' && !event.metaKey && model.state.visibility === 'visible') {
39
+ const element = document.querySelector(`[data-id="${model.state.cursorId}"]`);
40
+ if (element && (element === null || element === void 0 ? void 0 : element.getAttribute('aria-disabled')) !== 'true') {
41
+ model.events.select({ id: model.state.cursorId });
42
+ if (model.state.mode === 'single') {
43
+ model.events.hide(event);
44
+ }
45
+ }
46
+ // We don't want to submit forms while the combobox is open
47
+ event.preventDefault();
48
+ }
49
+ },
50
+ onBlur(event) {
51
+ model.events.hide(event);
52
+ },
53
+ onChange: model.onChange,
54
+ onClick(event) {
55
+ if (model.state.visibility === 'hidden') {
56
+ model.events.setWidth(event.currentTarget.clientWidth);
57
+ }
58
+ },
59
+ value: model.state.value,
60
+ role: 'combobox',
61
+ 'aria-haspopup': true,
62
+ 'aria-expanded': model.state.visibility === 'visible',
63
+ 'aria-autocomplete': 'list',
64
+ 'aria-controls': `${model.state.id}-list`,
65
+ id: model.state.id,
66
+ ref: elementRef,
67
+ };
68
+ }), useSetPopupWidth, useComboboxInputOpenWithArrowKeys, useListActiveDescendant, useComboboxListKeyboardHandler, usePopupTarget);
@@ -20,10 +20,10 @@ export declare const useComboboxInputOpenWithArrowKeys: import("@workday/canvas-
20
20
  readonly current: number;
21
21
  };
22
22
  UNSTABLE_virtual: {
23
- virtualItems: import("../../collection/lib/react-virtual").VirtualItem[];
23
+ virtualItems: import("../../../collection/lib/react-virtual").VirtualItem[];
24
24
  totalSize: number;
25
- scrollToOffset: (index: number, options?: import("../../collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
26
- scrollToIndex: (index: number, options?: import("../../collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
25
+ scrollToOffset: (index: number, options?: import("../../../collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
26
+ scrollToIndex: (index: number, options?: import("../../../collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
27
27
  measure: () => void;
28
28
  };
29
29
  UNSTABLE_defaultItemHeight: number;
@@ -32,7 +32,7 @@ export declare const useComboboxInputOpenWithArrowKeys: import("@workday/canvas-
32
32
  indexRef: import("react").MutableRefObject<number>;
33
33
  nonInteractiveIds: string[];
34
34
  isVirtualized: boolean;
35
- items: import("../..").Item<any>[];
35
+ items: import("../../..").Item<any>[];
36
36
  mode: "multiple" | "single";
37
37
  value: string | undefined;
38
38
  inputRef: import("react").RefObject<HTMLInputElement>;
@@ -75,8 +75,8 @@ export declare const useComboboxInputOpenWithArrowKeys: import("@workday/canvas-
75
75
  }): void;
76
76
  };
77
77
  onChange: (event: import("react").ChangeEvent<HTMLInputElement>) => void;
78
- selection: import("../../collection/lib/useSelectionListModel").SelectionManager;
79
- navigation: import("../../collection/lib/useCursorListModel").NavigationManager;
78
+ selection: import("../../../collection/lib/useSelectionListModel").SelectionManager;
79
+ navigation: import("../../../collection/lib/useCursorListModel").NavigationManager;
80
80
  getId: (item: any) => string;
81
81
  }, {
82
82
  onKeyDown(event: React.KeyboardEvent): void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComboboxInputOpenWithArrowKeys.d.ts","sourceRoot":"","sources":["../../../../../combobox/lib/hooks/useComboboxInputOpenWithArrowKeys.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAEzB,mBAAmB;EAUtC,CAAC"}
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ /**
3
+ * `useComboboxKeyboardTypeAhead` handles type-ahead. It will try and find a matching item in the list. It also returns the keys types so far.
4
+ * This hook is best used when composing hooks and in conjunction with `useComboboxInput`.
5
+ *
6
+ * ```tsx
7
+ * // Example for a `Select` input
8
+ * export const useSelectInput = composeHooks(
9
+ * createElemPropsHook(useComboboxModel)((model, ref, elemProps: {keySofar?: string} = {}) => {
10
+ * return {
11
+ * onKeyDown(event: React.KeyboardEvent) {
12
+ * // onKeyDown logic ...
13
+ * },
14
+ * } as const;
15
+ * }),
16
+ * useComboboxKeyboardTypeAhead,
17
+ * useComboboxInput
18
+ * );
19
+ * ```
20
+ */
21
+ export declare const useComboboxKeyboardTypeAhead: import("@workday/canvas-kit-react/common").BehaviorHook<{
22
+ state: {
23
+ stackRef: React.RefObject<HTMLDivElement>;
24
+ targetRef: React.RefObject<HTMLButtonElement>;
25
+ initialFocusRef: React.RefObject<any> | undefined;
26
+ returnFocusRef: React.RefObject<any> | undefined;
27
+ placement: import("@popperjs/core").Placement;
28
+ id: string;
29
+ visibility: "hidden" | "visible";
30
+ selectedIds: string[] | "all";
31
+ unselectedIds: string[];
32
+ cursorId: string;
33
+ columnCount: number;
34
+ pageSizeRef: React.MutableRefObject<number>;
35
+ cursorIndexRef: {
36
+ readonly current: number;
37
+ };
38
+ UNSTABLE_virtual: {
39
+ virtualItems: import("../../../collection/lib/react-virtual").VirtualItem[];
40
+ totalSize: number;
41
+ scrollToOffset: (index: number, options?: import("../../../collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
42
+ scrollToIndex: (index: number, options?: import("../../../collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
43
+ measure: () => void;
44
+ };
45
+ UNSTABLE_defaultItemHeight: number;
46
+ containerRef: React.RefObject<HTMLDivElement>;
47
+ orientation: "horizontal" | "vertical";
48
+ indexRef: React.MutableRefObject<number>;
49
+ nonInteractiveIds: string[];
50
+ isVirtualized: boolean;
51
+ items: import("../../..").Item<any>[];
52
+ mode: "multiple" | "single";
53
+ value: string | undefined;
54
+ inputRef: React.RefObject<HTMLInputElement>;
55
+ width: number;
56
+ };
57
+ events: {
58
+ setWidth(width: number): void;
59
+ updatePlacement(data: {
60
+ placement: import("@popperjs/core").Placement;
61
+ }): void;
62
+ show(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
63
+ hide(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
64
+ select(data: {
65
+ id: string;
66
+ }): void;
67
+ selectAll(): void;
68
+ unselectAll(): void;
69
+ goTo(data: {
70
+ id: string;
71
+ }): void;
72
+ goToNext(): void;
73
+ goToPrevious(): void;
74
+ goToPreviousRow(): void;
75
+ goToNextRow(): void;
76
+ goToFirst(): void;
77
+ goToLast(): void;
78
+ goToFirstOfRow(): void;
79
+ goToLastOfRow(): void;
80
+ goToNextPage(): void;
81
+ goToPreviousPage(): void;
82
+ registerItem(data: {
83
+ item: any;
84
+ textValue: string;
85
+ }): void;
86
+ unregisterItem(data: {
87
+ id: string;
88
+ }): void;
89
+ updateItemHeight(data: {
90
+ value: number;
91
+ }): void;
92
+ };
93
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
94
+ selection: import("../../../collection/lib/useSelectionListModel").SelectionManager;
95
+ navigation: import("../../../collection/lib/useCursorListModel").NavigationManager;
96
+ getId: (item: any) => string;
97
+ }, {
98
+ onKeyDown(event: React.KeyboardEvent): void;
99
+ keySofar: string;
100
+ }>;
101
+ //# sourceMappingURL=useComboboxKeyboardTypeAhead.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComboboxKeyboardTypeAhead.d.ts","sourceRoot":"","sources":["../../../../../combobox/lib/hooks/useComboboxKeyboardTypeAhead.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA0EpB,mBAAmB;;EA6BtC,CAAC"}
@@ -0,0 +1,103 @@
1
+ import React from 'react';
2
+ import { createElemPropsHook } from '@workday/canvas-kit-react/common';
3
+ import { useComboboxModel } from './useComboboxModel';
4
+ /**
5
+ * `useComboboxKeyboardTypeAhead` handles type-ahead. It will try and find a matching item in the list. It also returns the keys types so far.
6
+ * This hook is best used when composing hooks and in conjunction with `useComboboxInput`.
7
+ *
8
+ * ```tsx
9
+ * // Example for a `Select` input
10
+ * export const useSelectInput = composeHooks(
11
+ * createElemPropsHook(useComboboxModel)((model, ref, elemProps: {keySofar?: string} = {}) => {
12
+ * return {
13
+ * onKeyDown(event: React.KeyboardEvent) {
14
+ * // onKeyDown logic ...
15
+ * },
16
+ * } as const;
17
+ * }),
18
+ * useComboboxKeyboardTypeAhead,
19
+ * useComboboxInput
20
+ * );
21
+ * ```
22
+ */
23
+ export const useComboboxKeyboardTypeAhead = createElemPropsHook(useComboboxModel)(model => {
24
+ const keySofar = React.useRef('');
25
+ const timer = React.useRef();
26
+ const [keyTypedSofar, setKeyTypedSofar] = React.useState(keySofar.current);
27
+ const startClearKeysSoFarTimer = () => {
28
+ if (timer.current) {
29
+ clearTimeout(timer.current);
30
+ }
31
+ timer.current = setTimeout(() => {
32
+ keySofar.current = '';
33
+ setKeyTypedSofar(keySofar.current);
34
+ }, 500);
35
+ };
36
+ // Based on the the key typed, this will try and find an index in the array where it matches the string
37
+ // so if a user types `de` it will try and find an index in the array whose id matches `de` like denver
38
+ const getIndexByStartString = (startIndex, startString, endIndex = model.state.items.length, ignoreDisabled = true) => {
39
+ for (let i = startIndex; i < endIndex; i++) {
40
+ const label = model.state.items[i].textValue.toLowerCase();
41
+ if (label.startsWith(startString.toLowerCase()) &&
42
+ (!ignoreDisabled ||
43
+ (ignoreDisabled && !model.state.nonInteractiveIds.includes(model.state.items[i].id)))) {
44
+ return i;
45
+ }
46
+ }
47
+ return -1;
48
+ };
49
+ const currentItem = model.navigation.getItem(model.state.cursorId, model);
50
+ const cursorFocusedIndex = currentItem.index;
51
+ const handleKeyboardTypeAhead = (key, numOptions) => {
52
+ // If the starting point is beyond the list of options, reset it
53
+ // to the beginning of the list
54
+ const startNumber = keySofar.current.length === 0 ? cursorFocusedIndex + 1 : cursorFocusedIndex;
55
+ const start = startNumber === numOptions ? 0 : startNumber;
56
+ // Keeps track of the current key types and adds to it
57
+ // if you type `de` vs `d` for denver
58
+ keySofar.current += key;
59
+ setKeyTypedSofar(keySofar.current);
60
+ startClearKeysSoFarTimer();
61
+ // First, look for a match from start to end
62
+ let matchIndex = getIndexByStartString(start, keySofar.current);
63
+ getIndexByStartString(start, keySofar.current);
64
+ // If a match isn't found between start and end, wrap the search
65
+ // around and search again from the beginning (0) to start
66
+ if (matchIndex === -1) {
67
+ matchIndex = getIndexByStartString(0, keySofar.current, start);
68
+ }
69
+ // A match was found...
70
+ if (matchIndex > -1) {
71
+ model.events.goTo({ id: model.state.items[matchIndex].id });
72
+ if (model.state.visibility === 'hidden') {
73
+ // If the menu is closed, fire the change event
74
+ // go to that item and select based on its id
75
+ model.events.select({ id: model.state.items[matchIndex].id });
76
+ }
77
+ }
78
+ };
79
+ return {
80
+ onKeyDown(event) {
81
+ // Call type ahead excluding backspace
82
+ if (event.key.length === 1 && event.key.match(/\S/)) {
83
+ handleKeyboardTypeAhead(event.key, model.state.items.length);
84
+ }
85
+ // If spacebar is typed
86
+ if ((event.key === 'Spacebar' || event.key === ' ') &&
87
+ model.state.visibility === 'visible' &&
88
+ keySofar.current !== '') {
89
+ // If the user is in the middle of typing a string, treat
90
+ // space key as type-ahead rather than option selection
91
+ handleKeyboardTypeAhead(' ', model.state.items.length);
92
+ }
93
+ if ((event.key === 'Spacebar' || event.key === ' ') &&
94
+ model.state.visibility === 'hidden' &&
95
+ keySofar.current !== '') {
96
+ // If the user is in the middle of typing a string, treat
97
+ // space key as type-ahead rather than option selection
98
+ handleKeyboardTypeAhead(' ', model.state.items.length);
99
+ }
100
+ },
101
+ keySofar: keyTypedSofar,
102
+ };
103
+ });
@@ -0,0 +1,84 @@
1
+ import React from 'react';
2
+ /**
3
+ * `useComboboxListKeyboardHandler` handle calling keyboard events like ArrowUp and ArrowDown only when the menu is visible.
4
+ */
5
+ export declare const useComboboxListKeyboardHandler: import("@workday/canvas-kit-react/common").BehaviorHook<{
6
+ state: {
7
+ stackRef: React.RefObject<HTMLDivElement>;
8
+ targetRef: React.RefObject<HTMLButtonElement>;
9
+ initialFocusRef: React.RefObject<any> | undefined;
10
+ returnFocusRef: React.RefObject<any> | undefined;
11
+ placement: import("@popperjs/core").Placement;
12
+ id: string;
13
+ visibility: "hidden" | "visible";
14
+ selectedIds: string[] | "all";
15
+ unselectedIds: string[];
16
+ cursorId: string;
17
+ columnCount: number;
18
+ pageSizeRef: React.MutableRefObject<number>;
19
+ cursorIndexRef: {
20
+ readonly current: number;
21
+ };
22
+ UNSTABLE_virtual: {
23
+ virtualItems: import("../../../collection/lib/react-virtual").VirtualItem[];
24
+ totalSize: number;
25
+ scrollToOffset: (index: number, options?: import("../../../collection/lib/react-virtual").ScrollToOffsetOptions | undefined) => void;
26
+ scrollToIndex: (index: number, options?: import("../../../collection/lib/react-virtual").ScrollToIndexOptions | undefined) => void;
27
+ measure: () => void;
28
+ };
29
+ UNSTABLE_defaultItemHeight: number;
30
+ containerRef: React.RefObject<HTMLDivElement>;
31
+ orientation: "horizontal" | "vertical";
32
+ indexRef: React.MutableRefObject<number>;
33
+ nonInteractiveIds: string[];
34
+ isVirtualized: boolean;
35
+ items: import("@workday/canvas-kit-react/collection").Item<any>[];
36
+ mode: "multiple" | "single";
37
+ value: string | undefined;
38
+ inputRef: React.RefObject<HTMLInputElement>;
39
+ width: number;
40
+ };
41
+ events: {
42
+ setWidth(width: number): void;
43
+ updatePlacement(data: {
44
+ placement: import("@popperjs/core").Placement;
45
+ }): void;
46
+ show(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
47
+ hide(event?: Event | React.SyntheticEvent<Element, Event> | undefined): void;
48
+ select(data: {
49
+ id: string;
50
+ }): void;
51
+ selectAll(): void;
52
+ unselectAll(): void;
53
+ goTo(data: {
54
+ id: string;
55
+ }): void;
56
+ goToNext(): void;
57
+ goToPrevious(): void;
58
+ goToPreviousRow(): void;
59
+ goToNextRow(): void;
60
+ goToFirst(): void;
61
+ goToLast(): void;
62
+ goToFirstOfRow(): void;
63
+ goToLastOfRow(): void;
64
+ goToNextPage(): void;
65
+ goToPreviousPage(): void;
66
+ registerItem(data: {
67
+ item: any;
68
+ textValue: string;
69
+ }): void;
70
+ unregisterItem(data: {
71
+ id: string;
72
+ }): void;
73
+ updateItemHeight(data: {
74
+ value: number;
75
+ }): void;
76
+ };
77
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
78
+ selection: import("../../../collection/lib/useSelectionListModel").SelectionManager;
79
+ navigation: import("../../../collection/lib/useCursorListModel").NavigationManager;
80
+ getId: (item: any) => string;
81
+ }, {
82
+ onKeyDown(event: React.KeyboardEvent): void;
83
+ }>;
84
+ //# sourceMappingURL=useComboboxListKeyboardHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComboboxListKeyboardHandler.d.ts","sourceRoot":"","sources":["../../../../../combobox/lib/hooks/useComboboxListKeyboardHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B;;GAEG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAItB,mBAAmB;EAStC,CAAC"}