@jobber/components 6.85.2 → 6.85.3-CLEANUPre-6d043f4.28

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 (277) hide show
  1. package/dist/AtlantisThemeContext/AtlantisThemeContext.d.ts +1 -1
  2. package/dist/AtlantisThemeContext/index.d.ts +1 -1
  3. package/dist/AtlantisThemeContext/types.d.ts +17 -0
  4. package/dist/AtlantisThemeContext-cjs.js +38 -12
  5. package/dist/AtlantisThemeContext-es.js +40 -14
  6. package/dist/Autocomplete/Autocomplete.d.ts +3 -3
  7. package/dist/Autocomplete/Autocomplete.rebuilt.d.ts +8 -0
  8. package/dist/Autocomplete/Autocomplete.types.d.ts +388 -4
  9. package/dist/Autocomplete/components/MenuList.d.ts +37 -0
  10. package/dist/Autocomplete/components/PersistentRegion.d.ts +18 -0
  11. package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +22 -0
  12. package/dist/Autocomplete/index.cjs +1335 -37
  13. package/dist/Autocomplete/index.d.ts +32 -2
  14. package/dist/Autocomplete/index.mjs +1326 -21
  15. package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +38 -0
  16. package/dist/Autocomplete/useAutocomplete.d.ts +66 -0
  17. package/dist/Autocomplete/utils/menuModel.d.ts +14 -0
  18. package/dist/Banner/index.cjs +1 -6
  19. package/dist/Banner/index.mjs +1 -6
  20. package/dist/Banner-cjs.js +2 -2
  21. package/dist/Banner-es.js +2 -2
  22. package/dist/Button-cjs.js +2 -2
  23. package/dist/Button-es.js +2 -2
  24. package/dist/Card/CardClickable.d.ts +3 -1
  25. package/dist/Card/CardHeader.d.ts +1 -1
  26. package/dist/Card/index.cjs +2 -4
  27. package/dist/Card/index.mjs +2 -4
  28. package/dist/Card/types.d.ts +19 -1
  29. package/dist/Card-cjs.js +14 -13
  30. package/dist/Card-es.js +14 -13
  31. package/dist/Chip/index.cjs +2 -3
  32. package/dist/Chip/index.mjs +2 -3
  33. package/dist/Chip-cjs.js +3 -3
  34. package/dist/Chip-es.js +3 -3
  35. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -0
  36. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -0
  37. package/dist/Chips/InternalChipDismissible/index.cjs +2 -3
  38. package/dist/Chips/InternalChipDismissible/index.mjs +2 -3
  39. package/dist/Chips/index.cjs +2 -3
  40. package/dist/Chips/index.mjs +2 -3
  41. package/dist/Combobox/Combobox.types.d.ts +3 -1
  42. package/dist/Combobox/components/ComboboxActivator/index.cjs +2 -3
  43. package/dist/Combobox/components/ComboboxActivator/index.mjs +2 -3
  44. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.cjs +1 -1
  45. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.mjs +1 -1
  46. package/dist/Combobox/components/ComboboxContent/ComboboxLoadMore/index.cjs +1 -1
  47. package/dist/Combobox/components/ComboboxContent/ComboboxLoadMore/index.mjs +1 -1
  48. package/dist/Combobox/components/ComboboxContent/index.cjs +2 -3
  49. package/dist/Combobox/components/ComboboxContent/index.mjs +2 -3
  50. package/dist/Combobox/components/ComboboxTrigger/index.cjs +2 -3
  51. package/dist/Combobox/components/ComboboxTrigger/index.mjs +2 -3
  52. package/dist/Combobox/index.cjs +2 -6
  53. package/dist/Combobox/index.mjs +2 -6
  54. package/dist/Combobox-cjs.js +2 -2
  55. package/dist/Combobox-es.js +2 -2
  56. package/dist/ComboboxAction-cjs.js +5 -3
  57. package/dist/ComboboxAction-es.js +5 -3
  58. package/dist/ComboboxContent-cjs.js +3 -4
  59. package/dist/ComboboxContent-es.js +4 -5
  60. package/dist/ComboboxLoadMore-cjs.js +2 -2
  61. package/dist/ComboboxLoadMore-es.js +2 -2
  62. package/dist/ComboboxOption-cjs.js +1 -1
  63. package/dist/ComboboxOption-es.js +1 -1
  64. package/dist/ConfirmationModal/index.cjs +2 -4
  65. package/dist/ConfirmationModal/index.mjs +2 -4
  66. package/dist/ConfirmationModal-cjs.js +2 -2
  67. package/dist/ConfirmationModal-es.js +2 -2
  68. package/dist/ContentBlock/index.cjs +1 -6
  69. package/dist/ContentBlock/index.mjs +1 -6
  70. package/dist/ContentBlock-cjs.js +2 -2
  71. package/dist/ContentBlock-es.js +2 -2
  72. package/dist/Countdown-cjs.js +0 -1
  73. package/dist/Countdown-es.js +0 -1
  74. package/dist/DataDump/index.cjs +2 -4
  75. package/dist/DataDump/index.mjs +2 -4
  76. package/dist/DataList/components/DataListActions/index.cjs +2 -5
  77. package/dist/DataList/components/DataListActions/index.mjs +2 -5
  78. package/dist/DataList/components/DataListActionsMenu/index.cjs +1 -5
  79. package/dist/DataList/components/DataListActionsMenu/index.mjs +1 -5
  80. package/dist/DataList/components/DataListBulkActions/index.cjs +2 -5
  81. package/dist/DataList/components/DataListBulkActions/index.mjs +2 -5
  82. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +2 -6
  83. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +2 -6
  84. package/dist/DataList/components/DataListFilters/index.cjs +2 -7
  85. package/dist/DataList/components/DataListFilters/index.mjs +2 -7
  86. package/dist/DataList/components/DataListHeader/DataListHeaderCheckbox.d.ts +1 -2
  87. package/dist/DataList/components/DataListHeader/index.cjs +2 -5
  88. package/dist/DataList/components/DataListHeader/index.mjs +2 -5
  89. package/dist/DataList/components/DataListHeaderTile/components/index.cjs +1 -2
  90. package/dist/DataList/components/DataListHeaderTile/components/index.mjs +1 -2
  91. package/dist/DataList/components/DataListHeaderTile/index.cjs +1 -3
  92. package/dist/DataList/components/DataListHeaderTile/index.mjs +1 -3
  93. package/dist/DataList/components/DataListItem/index.cjs +2 -5
  94. package/dist/DataList/components/DataListItem/index.mjs +2 -5
  95. package/dist/DataList/components/DataListItemActions/index.cjs +2 -5
  96. package/dist/DataList/components/DataListItemActions/index.mjs +2 -5
  97. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +2 -5
  98. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +2 -5
  99. package/dist/DataList/components/DataListItems/index.cjs +2 -5
  100. package/dist/DataList/components/DataListItems/index.mjs +2 -5
  101. package/dist/DataList/components/DataListLayout/index.cjs +2 -5
  102. package/dist/DataList/components/DataListLayout/index.mjs +2 -5
  103. package/dist/DataList/components/DataListLayoutActions/index.cjs +2 -5
  104. package/dist/DataList/components/DataListLayoutActions/index.mjs +2 -5
  105. package/dist/DataList/components/DataListLoadMore/index.cjs +1 -1
  106. package/dist/DataList/components/DataListLoadMore/index.mjs +1 -1
  107. package/dist/DataList/components/DataListOverflowFade/index.cjs +1 -1
  108. package/dist/DataList/components/DataListOverflowFade/index.mjs +1 -1
  109. package/dist/DataList/components/DataListSearch/index.cjs +1 -2
  110. package/dist/DataList/components/DataListSearch/index.mjs +1 -2
  111. package/dist/DataList/components/DataListStatusBar/index.cjs +1 -3
  112. package/dist/DataList/components/DataListStatusBar/index.mjs +1 -3
  113. package/dist/DataList/index.cjs +2 -7
  114. package/dist/DataList/index.mjs +2 -7
  115. package/dist/DataListActionsMenu-cjs.js +5 -8
  116. package/dist/DataListActionsMenu-es.js +5 -8
  117. package/dist/DataListHeaderTile-cjs.js +2 -2
  118. package/dist/DataListHeaderTile-es.js +2 -2
  119. package/dist/DataListItem-cjs.js +2 -0
  120. package/dist/DataListItem-es.js +2 -0
  121. package/dist/DataListLoadMore-cjs.js +2 -2
  122. package/dist/DataListLoadMore-es.js +2 -2
  123. package/dist/DataListOverflowFade-cjs.js +3 -3
  124. package/dist/DataListOverflowFade-es.js +3 -3
  125. package/dist/DataListSearch-cjs.js +2 -2
  126. package/dist/DataListSearch-es.js +2 -2
  127. package/dist/DataListSortingOptions-cjs.js +3 -4
  128. package/dist/DataListSortingOptions-es.js +3 -4
  129. package/dist/DataTable/index.cjs +4 -6
  130. package/dist/DataTable/index.mjs +4 -6
  131. package/dist/DataTable/test-utilities/index.cjs +1 -7
  132. package/dist/DataTable/test-utilities/index.mjs +1 -7
  133. package/dist/DataTable-cjs.js +4 -4
  134. package/dist/DataTable-es.js +4 -4
  135. package/dist/DataTableTable-cjs.js +8 -8
  136. package/dist/DataTableTable-es.js +8 -8
  137. package/dist/DatePicker/DatePickerActivator.d.ts +2 -4
  138. package/dist/DatePicker/index.cjs +5 -3
  139. package/dist/DatePicker/index.mjs +5 -3
  140. package/dist/DatePicker-cjs.js +11478 -8531
  141. package/dist/DatePicker-es.js +11483 -8517
  142. package/dist/Disclosure/index.cjs +1 -6
  143. package/dist/Disclosure/index.mjs +1 -6
  144. package/dist/Disclosure-cjs.js +3 -3
  145. package/dist/Disclosure-es.js +3 -3
  146. package/dist/FeatureSwitch/index.cjs +1 -1
  147. package/dist/FeatureSwitch/index.mjs +1 -1
  148. package/dist/FormField/FormFieldWrapper.d.ts +1 -1
  149. package/dist/FormField/hooks/useAtlantisReactHookForm.d.ts +1 -0
  150. package/dist/FormField/index.cjs +1 -0
  151. package/dist/FormField/index.mjs +1 -0
  152. package/dist/FormField-cjs.js +2 -21
  153. package/dist/FormField-es.js +2 -21
  154. package/dist/FormatFile/index.cjs +2 -4
  155. package/dist/FormatFile/index.mjs +2 -4
  156. package/dist/Gallery/index.cjs +2 -7
  157. package/dist/Gallery/index.mjs +2 -7
  158. package/dist/Heading/Heading.d.ts +7 -1
  159. package/dist/Heading-cjs.js +2 -2
  160. package/dist/Heading-es.js +2 -2
  161. package/dist/InlineLabel/InlineLabel.d.ts +1 -1
  162. package/dist/InlineLabel-cjs.js +2 -1
  163. package/dist/InlineLabel-es.js +2 -1
  164. package/dist/InputDate/InputDate.types.d.ts +0 -12
  165. package/dist/InputDate/index.cjs +9 -30
  166. package/dist/InputDate/index.mjs +9 -30
  167. package/dist/InputEmail/index.cjs +1 -0
  168. package/dist/InputEmail/index.mjs +1 -0
  169. package/dist/InputFile/InputFile.d.ts +5 -1
  170. package/dist/InputFile-cjs.js +2 -2
  171. package/dist/InputFile-es.js +2 -2
  172. package/dist/InputNumber/index.cjs +3698 -2959
  173. package/dist/InputNumber/index.mjs +3698 -2959
  174. package/dist/InputPassword/index.cjs +1 -0
  175. package/dist/InputPassword/index.mjs +1 -0
  176. package/dist/InputPassword-cjs.js +1 -0
  177. package/dist/InputPassword-es.js +1 -0
  178. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +1 -1
  179. package/dist/InputPhoneNumber/index.cjs +1 -0
  180. package/dist/InputPhoneNumber/index.mjs +1 -0
  181. package/dist/InputText/InputText.d.ts +2 -2
  182. package/dist/InputText/index.cjs +3 -3
  183. package/dist/InputText/index.mjs +3 -3
  184. package/dist/InputText/useInputTextFormField.d.ts +6 -6
  185. package/dist/InputTime/index.cjs +1 -0
  186. package/dist/InputTime/index.mjs +2 -1
  187. package/dist/InternalChipDismissible-cjs.js +1 -0
  188. package/dist/InternalChipDismissible-es.js +1 -0
  189. package/dist/LightBox/index.cjs +1 -6
  190. package/dist/LightBox/index.mjs +1 -6
  191. package/dist/LightBox-cjs.js +12 -74
  192. package/dist/LightBox-es.js +12 -74
  193. package/dist/List/index.cjs +1 -1
  194. package/dist/List/index.mjs +1 -1
  195. package/dist/Markdown/index.cjs +1 -1
  196. package/dist/Markdown/index.mjs +1 -1
  197. package/dist/Markdown-cjs.js +20540 -18350
  198. package/dist/Markdown-es.js +20541 -18351
  199. package/dist/Menu/index.cjs +2 -4
  200. package/dist/Menu/index.mjs +2 -4
  201. package/dist/Menu-cjs.js +5 -37
  202. package/dist/Menu-es.js +6 -38
  203. package/dist/Modal/Modal.rebuilt.d.ts +1 -1
  204. package/dist/Modal/index.cjs +25 -22
  205. package/dist/Modal/index.mjs +26 -23
  206. package/dist/Page/index.cjs +3 -11
  207. package/dist/Page/index.mjs +3 -11
  208. package/dist/Page-cjs.js +5 -5
  209. package/dist/Page-es.js +5 -5
  210. package/dist/Popover/index.cjs +2 -1
  211. package/dist/Popover/index.mjs +2 -1
  212. package/dist/Popover/usePopover.d.ts +1 -1
  213. package/dist/Popover-cjs.js +2 -2
  214. package/dist/Popover-es.js +3 -3
  215. package/dist/RecurringSelect/index.cjs +2 -0
  216. package/dist/RecurringSelect/index.mjs +2 -0
  217. package/dist/Select/index.cjs +1 -0
  218. package/dist/Select/index.mjs +1 -0
  219. package/dist/SideDrawer/index.cjs +1 -5
  220. package/dist/SideDrawer/index.mjs +1 -5
  221. package/dist/SideDrawer-cjs.js +7 -10
  222. package/dist/SideDrawer-es.js +7 -10
  223. package/dist/Tabs/index.cjs +0 -1
  224. package/dist/Tabs/index.mjs +0 -1
  225. package/dist/Tabs-cjs.js +76 -2
  226. package/dist/Tabs-es.js +76 -2
  227. package/dist/Tooltip/index.cjs +2 -2
  228. package/dist/Tooltip/index.mjs +2 -2
  229. package/dist/Tooltip/useTooltipPositioning.d.ts +1 -1
  230. package/dist/Tooltip-cjs.js +3 -4
  231. package/dist/Tooltip-es.js +4 -5
  232. package/dist/_baseEach-es.js +1 -1
  233. package/dist/_commonjsHelpers-cjs.js +0 -26
  234. package/dist/_commonjsHelpers-es.js +1 -26
  235. package/dist/_isIterateeCall-es.js +1 -1
  236. package/dist/clsx-cjs.js +5 -0
  237. package/dist/clsx-es.js +3 -0
  238. package/dist/debounce-es.js +2 -2
  239. package/dist/floating-ui.react-cjs.js +2106 -2225
  240. package/dist/floating-ui.react-es.js +2105 -2226
  241. package/dist/helpers-cjs.js +21 -2
  242. package/dist/helpers-es.js +1 -1
  243. package/dist/index.cjs +15 -21
  244. package/dist/index.mjs +11 -17
  245. package/dist/isObjectLike-es.js +1 -1
  246. package/dist/isSymbol-es.js +1 -1
  247. package/dist/isTypedArray-es.js +1 -1
  248. package/dist/keysIn-es.js +1 -1
  249. package/dist/omit-es.js +1 -1
  250. package/dist/styles.css +719 -509
  251. package/dist/tslib.es6-cjs.js +3 -3
  252. package/dist/tslib.es6-es.js +3 -3
  253. package/dist/useScrollToActive-cjs.js +3 -45
  254. package/dist/useScrollToActive-es.js +5 -47
  255. package/dist/utils/mockLargeViewport.d.ts +33 -0
  256. package/package.json +13 -19
  257. package/rollup.config.mjs +1 -15
  258. package/dist/Autocomplete-cjs.js +0 -357
  259. package/dist/Autocomplete-es.js +0 -344
  260. package/dist/throttle-cjs.js +0 -80
  261. package/dist/throttle-es.js +0 -77
  262. package/dist/useDebounce-cjs.js +0 -4415
  263. package/dist/useDebounce-es.js +0 -4413
  264. package/dist/useFocusTrap-cjs.js +0 -75
  265. package/dist/useFocusTrap-es.js +0 -73
  266. package/dist/useInView-cjs.js +0 -26
  267. package/dist/useInView-es.js +0 -24
  268. package/dist/useIsMounted-cjs.js +0 -51
  269. package/dist/useIsMounted-es.js +0 -49
  270. package/dist/useOnKeyDown-cjs.js +0 -41
  271. package/dist/useOnKeyDown-es.js +0 -39
  272. package/dist/useRefocusOnActivator-cjs.js +0 -33
  273. package/dist/useRefocusOnActivator-es.js +0 -31
  274. package/dist/useResizeObserver-cjs.js +0 -1131
  275. package/dist/useResizeObserver-es.js +0 -1128
  276. package/dist/useSafeLayoutEffect-cjs.js +0 -14
  277. package/dist/useSafeLayoutEffect-es.js +0 -12
@@ -1,344 +0,0 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-es.js';
2
- import React__default, { useCallback, useEffect, useState, forwardRef, useMemo, useRef } from 'react';
3
- import { u as useDebounce_2 } from './useDebounce-es.js';
4
- import classnames from 'classnames';
5
- import { u as useIsMounted_2 } from './useIsMounted-es.js';
6
- import { u as useFloating, o as offset, f as flip, e as size, b as autoUpdate, F as FloatingPortal } from './floating-ui.react-es.js';
7
- import { u as useSafeLayoutEffect_1 } from './useSafeLayoutEffect-es.js';
8
- import { c as calculateMaxHeight } from './maxHeight-es.js';
9
- import { H as Heading } from './Heading-es.js';
10
- import { T as Text } from './Text-es.js';
11
- import { I as Icon } from './Icon-es.js';
12
- import { u as useOnKeyDown_2 } from './useOnKeyDown-es.js';
13
- import { InputText } from './InputText/index.mjs';
14
- import { m as mergeRefs } from './FormField-es.js';
15
-
16
- var styles = {"autocomplete":"_7mObJiwfPh4-","options":"dL5JShAJlKM-","heading":"PWZL-94hH7k-","visible":"_2RzcnTdaPyc-","option":"y9zhi8Wr8QA-","active":"_3Xg49dtL1Q8-","separator":"LIeh390F3W8-","icon":"K2phy6IC3TY-","text":"a6-LbUm5WnY-","label":"tQNbuxcE9nU-","details":"qacStG9-XbE-","spinning":"P9cQDL4MZ-s-"};
17
-
18
- const AUTOCOMPLETE_MAX_HEIGHT = 300;
19
-
20
- function useRepositionMenu(attachTo, visible, cssManagedVisibility) {
21
- const { refs, floatingStyles, update } = useFloating(Object.assign({ placement: "bottom", middleware: [
22
- offset(8),
23
- flip({ fallbackPlacements: ["top"] }),
24
- size({
25
- apply({ availableHeight, elements }) {
26
- const maxHeight = calculateMaxHeight(availableHeight, {
27
- maxHeight: AUTOCOMPLETE_MAX_HEIGHT,
28
- });
29
- Object.assign(elements.floating.style, {
30
- maxHeight: `${maxHeight}px`,
31
- });
32
- },
33
- }),
34
- ], elements: {
35
- reference: attachTo,
36
- } }, (!cssManagedVisibility
37
- ? {
38
- whileElementsMounted: autoUpdate,
39
- }
40
- : {})));
41
- // While DefaultMenu leverages conditional rendering, CustomMenu is hidden with CSS
42
- // We need to apply the correct update method to each case
43
- useSafeLayoutEffect_1(() => {
44
- if (cssManagedVisibility && visible && attachTo && refs.floating.current) {
45
- const cleanup = autoUpdate(attachTo, refs.floating.current, update);
46
- return cleanup;
47
- }
48
- return undefined;
49
- }, [
50
- cssManagedVisibility,
51
- visible,
52
- attachTo,
53
- refs.floating.current,
54
- update,
55
- autoUpdate,
56
- ]);
57
- const targetWidth = attachTo === null || attachTo === void 0 ? void 0 : attachTo.clientWidth;
58
- return {
59
- menuRef: refs.floating.current,
60
- setMenuRef: refs.setFloating,
61
- targetWidth,
62
- styles: {
63
- float: floatingStyles,
64
- },
65
- };
66
- }
67
-
68
- function BaseAutocompleteMenuWrapperInternal({ setMenuRef, floatStyles, targetWidth, visible, children, }) {
69
- return (React__default.createElement("div", { className: classnames(styles.options, { [styles.visible]: visible }), ref: setMenuRef, style: Object.assign(Object.assign({}, floatStyles.float), { width: targetWidth }), "data-elevation": "elevated" }, children));
70
- }
71
- /**
72
- * Provides a wrapper for the Autocomplete menu that handles positioning and visibility.
73
- * @param attachTo - The element that the menu should be attached to.
74
- */
75
- function useAutocompleteMenu({ attachTo, }) {
76
- const [menuRef, setMenuRef] = React__default.useState(null);
77
- const AutocompleteMenuWrapper = useCallback(({ children, visible, }) => {
78
- const menuFloatProps = useRepositionMenu(attachTo, visible, true);
79
- useEffect(() => {
80
- setMenuRef(menuFloatProps.menuRef);
81
- }, [menuFloatProps.menuRef]);
82
- return (React__default.createElement(BaseAutocompleteMenuWrapper, { floatStyles: menuFloatProps.styles, setMenuRef: menuFloatProps.setMenuRef, targetWidth: menuFloatProps.targetWidth, visible: visible }, children));
83
- }, [attachTo]);
84
- return { MenuWrapper: AutocompleteMenuWrapper, menuRef };
85
- }
86
- function BaseAutocompleteMenuWrapper(props) {
87
- const mounted = useIsMounted_2();
88
- const menu = React__default.createElement(BaseAutocompleteMenuWrapperInternal, Object.assign({}, props));
89
- return mounted.current ? React__default.createElement(FloatingPortal, null, menu) : menu;
90
- }
91
-
92
- function isOptionSelected(selectedOption, option) {
93
- return Boolean(selectedOption && selectedOption.value === option.value);
94
- }
95
- /**
96
- * Helper function to determine if the option is a group. This is used to
97
- * determine if the option contains a list of options for rendering Section
98
- * Labels in the Autocomplete component.
99
- */
100
- function isOptionGroup(option) {
101
- return "options" in option;
102
- }
103
-
104
- /**
105
- * The rendering of the default MenuOption
106
- */
107
- function MenuOption({ isHighlighted, option, onOptionSelect, isSelected, addSeparators, UNSAFE_className = {}, UNSAFE_style = {}, }) {
108
- if (isOptionGroup(option)) {
109
- return (React__default.createElement(MenuGroupOptions, { UNSAFE_className: UNSAFE_className.groupOption, option: option, UNSAFE_style: UNSAFE_style.groupOption }));
110
- }
111
- return (React__default.createElement(BaseMenuOption, { UNSAFE_className: UNSAFE_className.option, UNSAFE_style: UNSAFE_style.option, option: option, isHighlighted: isHighlighted, onOptionSelect: onOptionSelect, addSeparators: addSeparators },
112
- React__default.createElement(MenuOptionContent, { option: option, isSelected: isSelected, UNSAFE_className: UNSAFE_className.content, UNSAFE_style: UNSAFE_style.content })));
113
- }
114
- function MenuOptionContent({ option, isSelected, UNSAFE_className = {}, UNSAFE_style = {}, }) {
115
- const iconClassName = classnames(styles.icon, UNSAFE_className.icon);
116
- const textClassName = classnames(styles.text, UNSAFE_className.text);
117
- const labelClassName = classnames(styles.label, UNSAFE_className.label);
118
- const detailsClassName = classnames(styles.details, UNSAFE_className.details);
119
- return (React__default.createElement(React__default.Fragment, null,
120
- React__default.createElement("div", { className: iconClassName, style: UNSAFE_style.icon }, isSelected && React__default.createElement(Icon, { name: "checkmark", size: "small" })),
121
- React__default.createElement("div", { className: textClassName, style: UNSAFE_style.text },
122
- React__default.createElement("div", { className: labelClassName, style: UNSAFE_style.label },
123
- React__default.createElement(Text, null, option.label),
124
- option.description !== undefined && (React__default.createElement(Text, { variation: "subdued" }, option.description))),
125
- option.details !== undefined && (React__default.createElement("div", { className: detailsClassName, style: UNSAFE_style.details },
126
- React__default.createElement(Text, null, option.details))))));
127
- }
128
- /**
129
- * The rendering of the default MenuGroupOption
130
- */
131
- function MenuGroupOptions({ option, UNSAFE_className = {}, UNSAFE_style = {}, }) {
132
- return (React__default.createElement(BaseMenuGroupOption, { UNSAFE_className: UNSAFE_className.heading, UNSAFE_style: UNSAFE_style.heading },
133
- React__default.createElement(Heading, { level: 5 }, option.label)));
134
- }
135
- function BaseMenuGroupOption({ children, UNSAFE_className = "", UNSAFE_style = {}, }) {
136
- const headingClassName = classnames(styles.heading, UNSAFE_className);
137
- return (React__default.createElement("div", { className: headingClassName, style: UNSAFE_style }, children));
138
- }
139
- /**
140
- * Renders the base option component. The component takes children and renders them inside a button.
141
- */
142
- function BaseMenuOption({ option, isHighlighted, onOptionSelect, addSeparators, children, UNSAFE_className = "", UNSAFE_style = {}, }) {
143
- const optionClass = classnames(styles.option, {
144
- [styles.active]: isHighlighted,
145
- [styles.separator]: addSeparators,
146
- }, UNSAFE_className);
147
- return (React__default.createElement("button", { role: "option", type: "button", className: optionClass, onMouseDown: onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect.bind(undefined, option), style: UNSAFE_style }, children));
148
- }
149
-
150
- var KeyboardAction;
151
- (function (KeyboardAction) {
152
- KeyboardAction[KeyboardAction["Previous"] = -1] = "Previous";
153
- KeyboardAction[KeyboardAction["Next"] = 1] = "Next";
154
- KeyboardAction[KeyboardAction["Select"] = 0] = "Select";
155
- })(KeyboardAction || (KeyboardAction = {}));
156
- /**
157
- * Hook to handle custom keyboard navigation for the Autocomplete component.
158
- * Use this hook if you are using components in the menu that aren't MenuOption or BaseMenuOption.
159
- */
160
- function useCustomKeyboardNavigation({ onRequestHighlightChange, }) {
161
- useOnKeyDown_2((event) => {
162
- onRequestHighlightChange === null || onRequestHighlightChange === void 0 ? void 0 : onRequestHighlightChange(event, KeyboardAction.Next);
163
- }, "ArrowDown");
164
- useOnKeyDown_2((event) => {
165
- onRequestHighlightChange === null || onRequestHighlightChange === void 0 ? void 0 : onRequestHighlightChange(event, KeyboardAction.Previous);
166
- }, "ArrowUp");
167
- useOnKeyDown_2((event) => {
168
- onRequestHighlightChange === null || onRequestHighlightChange === void 0 ? void 0 : onRequestHighlightChange(event, KeyboardAction.Select);
169
- }, "Enter");
170
- }
171
- /**
172
- * Hook to handle keyboard navigation for the Menu in the Autocomplete component.
173
- * If using components in the menu that aren't MenuOption or BaseMenuOption, you should use the `useCustomKeyboardNavigation` hook.
174
- */
175
- function useKeyboardNavigation({ options, onOptionSelect, menuRef, visible, }) {
176
- const [highlightedIndex, setHighlightedIndex] = useState(0);
177
- const initialHighlight = options.some(isOptionGroup) ? 1 : 0;
178
- useEffect(() => setHighlightedIndex(initialHighlight), [options]);
179
- useEffect(() => {
180
- var _a, _b;
181
- (_b = (_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.children[highlightedIndex]) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, {
182
- behavior: "smooth",
183
- block: "nearest",
184
- inline: "start",
185
- });
186
- }, [highlightedIndex]);
187
- const onRequestHighlightChange = useCallback((event, direction) => {
188
- if (!visible)
189
- return;
190
- const indexChange = getRequestedIndexChange({
191
- event,
192
- options,
193
- direction,
194
- highlightedIndex,
195
- });
196
- switch (direction) {
197
- case KeyboardAction.Previous:
198
- setHighlightedIndex(prev => Math.max(0, prev + indexChange));
199
- break;
200
- case KeyboardAction.Next:
201
- setHighlightedIndex(prev => Math.min(options.length - 1, prev + indexChange));
202
- break;
203
- case KeyboardAction.Select:
204
- if (isOptionGroup(options[highlightedIndex]))
205
- return;
206
- onOptionSelect(options[highlightedIndex]);
207
- break;
208
- }
209
- }, [highlightedIndex, options, onOptionSelect, visible]);
210
- useCustomKeyboardNavigation({ onRequestHighlightChange });
211
- return { highlightedIndex };
212
- }
213
- /**
214
- * Function to get the requested index change based on the current highlighted index and the direction of the keyboard action.
215
- * Accounts for groups in the options array.
216
- */
217
- function getRequestedIndexChange({ event, options, direction, highlightedIndex, }) {
218
- event.preventDefault();
219
- const requestedIndex = options[highlightedIndex + direction];
220
- return requestedIndex && isOptionGroup(requestedIndex)
221
- ? direction + direction
222
- : direction;
223
- }
224
-
225
- /**
226
- * Renders the default Menu for the Autocomplete component.
227
- */
228
- function DefaultMenu({ options, selectedOption, onOptionSelect, attachTo, visible, }) {
229
- const { menuRef, setMenuRef, styles: floatStyles, targetWidth, } = useRepositionMenu(attachTo, visible, false);
230
- const detectSeparatorCondition = (option) => option.description || option.details;
231
- const addSeparators = options.some(detectSeparatorCondition);
232
- const { highlightedIndex } = useKeyboardNavigation({
233
- onOptionSelect,
234
- options,
235
- visible,
236
- menuRef,
237
- });
238
- return (React__default.createElement(BaseAutocompleteMenuWrapper, { setMenuRef, floatStyles, targetWidth, visible }, options === null || options === void 0 ? void 0 : options.map((option, index) => {
239
- return (React__default.createElement(MenuOption, { key: index, option: option, isHighlighted: index === highlightedIndex, onOptionSelect: onOptionSelect, isSelected: isOptionSelected(selectedOption, option), addSeparators: addSeparators }));
240
- })));
241
- }
242
-
243
- function Menu({ options, selectedOption, onOptionSelect, inputFocused, attachTo, inputRef, customRenderMenu, }) {
244
- if (customRenderMenu) {
245
- return (React__default.createElement(CustomMenu, { attachTo: attachTo, inputFocused: inputFocused, inputRef: inputRef, customRenderMenu: customRenderMenu, options: options, onOptionSelect: onOptionSelect, selectedOption: selectedOption }));
246
- }
247
- if (!inputFocused || !options.length)
248
- return null;
249
- return (React__default.createElement(DefaultMenu, { attachTo: attachTo, options: options, onOptionSelect: onOptionSelect, selectedOption: selectedOption, visible: inputFocused }));
250
- }
251
- /**
252
- * Renders the custom Menu for the Autocomplete component.
253
- * Provides the menuRef and MenuWrapper to the customRenderMenu function.
254
- */
255
- function CustomMenu({ options, selectedOption, onOptionSelect, customRenderMenu, attachTo, inputFocused, inputRef, }) {
256
- const { MenuWrapper, menuRef } = useAutocompleteMenu({ attachTo });
257
- const menuContent = customRenderMenu({
258
- options,
259
- menuRef,
260
- onOptionSelect,
261
- selectedOption,
262
- inputFocused,
263
- MenuWrapper,
264
- inputRef,
265
- });
266
- return menuContent;
267
- }
268
-
269
- // Max statements increased to make room for the debounce functions
270
- // eslint-disable-next-line max-statements
271
- function AutocompleteInternal(_a, ref) {
272
- var _b;
273
- var { initialOptions = [], value, allowFreeForm = true, size = undefined, debounce: debounceRate = 300, onChange, getOptions, placeholder, onBlur, onFocus, validations, customRenderMenu } = _a, inputProps = __rest(_a, ["initialOptions", "value", "allowFreeForm", "size", "debounce", "onChange", "getOptions", "placeholder", "onBlur", "onFocus", "validations", "customRenderMenu"]);
274
- const initialOptionsMemo = useMemo(() => mapToOptions(initialOptions), [initialOptions]);
275
- const [options, setOptions] = useState(initialOptionsMemo);
276
- const [inputFocused, setInputFocused] = useState(false);
277
- const [inputText, setInputText] = useState((_b = value === null || value === void 0 ? void 0 : value.label) !== null && _b !== void 0 ? _b : "");
278
- const [autocompleteRef, setAutocompleteRef] = useState(null);
279
- const delayedSearch = useDebounce_2(updateSearch, debounceRate);
280
- const inputRef = useRef(null);
281
- useEffect(() => {
282
- delayedSearch();
283
- }, [inputText]);
284
- useEffect(() => {
285
- var _a;
286
- updateInput((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
287
- }, [value]);
288
- return (React__default.createElement("div", { className: styles.autocomplete, ref: setAutocompleteRef },
289
- React__default.createElement(InputText, Object.assign({ ref: mergeRefs([ref, inputRef]), autocomplete: false, size: size, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, validations: validations }, inputProps)),
290
- React__default.createElement(Menu, { attachTo: autocompleteRef, inputRef: inputRef, inputFocused: inputFocused, options: options, customRenderMenu: customRenderMenu, selectedOption: value, onOptionSelect: handleMenuChange })));
291
- function updateInput(newText) {
292
- setInputText(newText);
293
- if (newText === "") {
294
- setOptions(mapToOptions(initialOptions));
295
- }
296
- }
297
- function updateSearch() {
298
- return __awaiter(this, void 0, void 0, function* () {
299
- const updatedOptions = yield getOptions(inputText);
300
- const filteredOptions = updatedOptions.filter(option => isOptionGroup(option) ? option.options.length > 0 : true);
301
- setOptions(mapToOptions(filteredOptions));
302
- });
303
- }
304
- function handleMenuChange(chosenOption) {
305
- var _a;
306
- onChange(chosenOption);
307
- updateInput((_a = chosenOption === null || chosenOption === void 0 ? void 0 : chosenOption.label) !== null && _a !== void 0 ? _a : "");
308
- setInputFocused(false);
309
- }
310
- function handleInputChange(newText) {
311
- updateInput(newText);
312
- if (allowFreeForm) {
313
- onChange({ label: newText });
314
- }
315
- }
316
- function handleInputBlur() {
317
- setInputFocused(false);
318
- if (value == undefined || value.label !== inputText) {
319
- setInputText("");
320
- onChange(undefined);
321
- }
322
- onBlur && onBlur();
323
- }
324
- function handleInputFocus() {
325
- setInputFocused(true);
326
- if (onFocus) {
327
- onFocus();
328
- }
329
- }
330
- }
331
- function mapToOptions(items) {
332
- const retVal = items.reduce((result, item) => {
333
- result.push(item);
334
- if (isOptionGroup(item) && item.options) {
335
- result = result.concat(item.options);
336
- }
337
- return result;
338
- }, []);
339
- return retVal;
340
- }
341
- // Casts the Generics to the forward ref so autocomplete works as expected for consumers
342
- const Autocomplete = forwardRef(AutocompleteInternal);
343
-
344
- export { Autocomplete as A, BaseMenuOption as B, KeyboardAction as K, MenuOption as M, BaseMenuGroupOption as a, useCustomKeyboardNavigation as b, useRepositionMenu as c, BaseAutocompleteMenuWrapper as d, useAutocompleteMenu as e, isOptionGroup as f, getRequestedIndexChange as g, isOptionSelected as i, useKeyboardNavigation as u };
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- var _commonjsHelpers = require('./_commonjsHelpers-cjs.js');
4
- var debounce$1 = require('./debounce-cjs.js');
5
- var isObjectLike = require('./isObjectLike-cjs.js');
6
-
7
- var debounce = debounce$1.debounce_1,
8
- isObject = isObjectLike.isObject_1;
9
-
10
- /** Error message constants. */
11
- var FUNC_ERROR_TEXT = 'Expected a function';
12
-
13
- /**
14
- * Creates a throttled function that only invokes `func` at most once per
15
- * every `wait` milliseconds. The throttled function comes with a `cancel`
16
- * method to cancel delayed `func` invocations and a `flush` method to
17
- * immediately invoke them. Provide `options` to indicate whether `func`
18
- * should be invoked on the leading and/or trailing edge of the `wait`
19
- * timeout. The `func` is invoked with the last arguments provided to the
20
- * throttled function. Subsequent calls to the throttled function return the
21
- * result of the last `func` invocation.
22
- *
23
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
24
- * invoked on the trailing edge of the timeout only if the throttled function
25
- * is invoked more than once during the `wait` timeout.
26
- *
27
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
28
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
29
- *
30
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
31
- * for details over the differences between `_.throttle` and `_.debounce`.
32
- *
33
- * @static
34
- * @memberOf _
35
- * @since 0.1.0
36
- * @category Function
37
- * @param {Function} func The function to throttle.
38
- * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
39
- * @param {Object} [options={}] The options object.
40
- * @param {boolean} [options.leading=true]
41
- * Specify invoking on the leading edge of the timeout.
42
- * @param {boolean} [options.trailing=true]
43
- * Specify invoking on the trailing edge of the timeout.
44
- * @returns {Function} Returns the new throttled function.
45
- * @example
46
- *
47
- * // Avoid excessively updating the position while scrolling.
48
- * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
49
- *
50
- * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
51
- * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
52
- * jQuery(element).on('click', throttled);
53
- *
54
- * // Cancel the trailing throttled invocation.
55
- * jQuery(window).on('popstate', throttled.cancel);
56
- */
57
- function throttle(func, wait, options) {
58
- var leading = true,
59
- trailing = true;
60
-
61
- if (typeof func != 'function') {
62
- throw new TypeError(FUNC_ERROR_TEXT);
63
- }
64
- if (isObject(options)) {
65
- leading = 'leading' in options ? !!options.leading : leading;
66
- trailing = 'trailing' in options ? !!options.trailing : trailing;
67
- }
68
- return debounce(func, wait, {
69
- 'leading': leading,
70
- 'maxWait': wait,
71
- 'trailing': trailing
72
- });
73
- }
74
-
75
- var throttle_1 = throttle;
76
-
77
- var throttle$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(throttle_1);
78
-
79
- exports.throttle = throttle$1;
80
- exports.throttle_1 = throttle_1;
@@ -1,77 +0,0 @@
1
- import { g as getDefaultExportFromCjs } from './_commonjsHelpers-es.js';
2
- import { d as debounce_1 } from './debounce-es.js';
3
- import { i as isObject_1 } from './isObjectLike-es.js';
4
-
5
- var debounce = debounce_1,
6
- isObject = isObject_1;
7
-
8
- /** Error message constants. */
9
- var FUNC_ERROR_TEXT = 'Expected a function';
10
-
11
- /**
12
- * Creates a throttled function that only invokes `func` at most once per
13
- * every `wait` milliseconds. The throttled function comes with a `cancel`
14
- * method to cancel delayed `func` invocations and a `flush` method to
15
- * immediately invoke them. Provide `options` to indicate whether `func`
16
- * should be invoked on the leading and/or trailing edge of the `wait`
17
- * timeout. The `func` is invoked with the last arguments provided to the
18
- * throttled function. Subsequent calls to the throttled function return the
19
- * result of the last `func` invocation.
20
- *
21
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
22
- * invoked on the trailing edge of the timeout only if the throttled function
23
- * is invoked more than once during the `wait` timeout.
24
- *
25
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
26
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
27
- *
28
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
29
- * for details over the differences between `_.throttle` and `_.debounce`.
30
- *
31
- * @static
32
- * @memberOf _
33
- * @since 0.1.0
34
- * @category Function
35
- * @param {Function} func The function to throttle.
36
- * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
37
- * @param {Object} [options={}] The options object.
38
- * @param {boolean} [options.leading=true]
39
- * Specify invoking on the leading edge of the timeout.
40
- * @param {boolean} [options.trailing=true]
41
- * Specify invoking on the trailing edge of the timeout.
42
- * @returns {Function} Returns the new throttled function.
43
- * @example
44
- *
45
- * // Avoid excessively updating the position while scrolling.
46
- * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
47
- *
48
- * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
49
- * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
50
- * jQuery(element).on('click', throttled);
51
- *
52
- * // Cancel the trailing throttled invocation.
53
- * jQuery(window).on('popstate', throttled.cancel);
54
- */
55
- function throttle(func, wait, options) {
56
- var leading = true,
57
- trailing = true;
58
-
59
- if (typeof func != 'function') {
60
- throw new TypeError(FUNC_ERROR_TEXT);
61
- }
62
- if (isObject(options)) {
63
- leading = 'leading' in options ? !!options.leading : leading;
64
- trailing = 'trailing' in options ? !!options.trailing : trailing;
65
- }
66
- return debounce(func, wait, {
67
- 'leading': leading,
68
- 'maxWait': wait,
69
- 'trailing': trailing
70
- });
71
- }
72
-
73
- var throttle_1 = throttle;
74
-
75
- var throttle$1 = /*@__PURE__*/getDefaultExportFromCjs(throttle_1);
76
-
77
- export { throttle_1 as a, throttle$1 as t };