@economic/taco 1.1.13-alpha.0 → 1.2.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 (213) hide show
  1. package/dist/components/Group/Group.d.ts +11 -1
  2. package/dist/components/Toast/Toast.d.ts +2 -2
  3. package/dist/components/Toast/Toaster.d.ts +2 -2
  4. package/dist/esm/components/Accordion/Accordion.js +31 -34
  5. package/dist/esm/components/Accordion/Accordion.js.map +1 -1
  6. package/dist/esm/components/Backdrop/Backdrop.js +2 -2
  7. package/dist/esm/components/Backdrop/Backdrop.js.map +1 -1
  8. package/dist/esm/components/Badge/Badge.js +14 -14
  9. package/dist/esm/components/Badge/Badge.js.map +1 -1
  10. package/dist/esm/components/Banner/Banner.js +7 -5
  11. package/dist/esm/components/Banner/Banner.js.map +1 -1
  12. package/dist/esm/components/Banner/util.js +1 -1
  13. package/dist/esm/components/Banner/util.js.map +1 -1
  14. package/dist/esm/components/Button/Button.js +12 -13
  15. package/dist/esm/components/Button/Button.js.map +1 -1
  16. package/dist/esm/components/Button/util.js +18 -23
  17. package/dist/esm/components/Button/util.js.map +1 -1
  18. package/dist/esm/components/Calendar/Calendar.js +56 -71
  19. package/dist/esm/components/Calendar/Calendar.js.map +1 -1
  20. package/dist/esm/components/Card/Card.js +13 -12
  21. package/dist/esm/components/Card/Card.js.map +1 -1
  22. package/dist/esm/components/Checkbox/Checkbox.js +15 -18
  23. package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
  24. package/dist/esm/components/Combobox/Combobox.js +23 -25
  25. package/dist/esm/components/Combobox/Combobox.js.map +1 -1
  26. package/dist/esm/components/Combobox/useCombobox.js +78 -99
  27. package/dist/esm/components/Combobox/useCombobox.js.map +1 -1
  28. package/dist/esm/components/Datepicker/Datepicker.js +48 -52
  29. package/dist/esm/components/Datepicker/Datepicker.js.map +1 -1
  30. package/dist/esm/components/Datepicker/useDatepicker.js +27 -34
  31. package/dist/esm/components/Datepicker/useDatepicker.js.map +1 -1
  32. package/dist/esm/components/Dialog/Context.js +4 -4
  33. package/dist/esm/components/Dialog/Context.js.map +1 -1
  34. package/dist/esm/components/Dialog/Dialog.js +39 -58
  35. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  36. package/dist/esm/components/Dialog/components/Content.js +39 -44
  37. package/dist/esm/components/Dialog/components/Content.js.map +1 -1
  38. package/dist/esm/components/Dialog/components/Drawer.js +3 -3
  39. package/dist/esm/components/Dialog/components/Drawer.js.map +1 -1
  40. package/dist/esm/components/Dialog/components/Extra.js +2 -2
  41. package/dist/esm/components/Dialog/components/Extra.js.map +1 -1
  42. package/dist/esm/components/Dialog/components/Trigger.js +2 -2
  43. package/dist/esm/components/Dialog/components/Trigger.js.map +1 -1
  44. package/dist/esm/components/Field/Field.js +10 -12
  45. package/dist/esm/components/Field/Field.js.map +1 -1
  46. package/dist/esm/components/Form/Form.js +6 -8
  47. package/dist/esm/components/Form/Form.js.map +1 -1
  48. package/dist/esm/components/Group/Group.js +9 -8
  49. package/dist/esm/components/Group/Group.js.map +1 -1
  50. package/dist/esm/components/Hanger/Hanger.js +27 -35
  51. package/dist/esm/components/Hanger/Hanger.js.map +1 -1
  52. package/dist/esm/components/HoverCard/HoverCard.js +8 -9
  53. package/dist/esm/components/HoverCard/HoverCard.js.map +1 -1
  54. package/dist/esm/components/Icon/Icon.js +7 -8
  55. package/dist/esm/components/Icon/Icon.js.map +1 -1
  56. package/dist/esm/components/Icon/components/index.js +4 -4
  57. package/dist/esm/components/Icon/components/index.js.map +1 -1
  58. package/dist/esm/components/IconButton/IconButton.js +9 -11
  59. package/dist/esm/components/IconButton/IconButton.js.map +1 -1
  60. package/dist/esm/components/Input/Input.js +25 -25
  61. package/dist/esm/components/Input/Input.js.map +1 -1
  62. package/dist/esm/components/Input/util.js +2 -2
  63. package/dist/esm/components/Input/util.js.map +1 -1
  64. package/dist/esm/components/Listbox/Listbox.js +24 -25
  65. package/dist/esm/components/Listbox/Listbox.js.map +1 -1
  66. package/dist/esm/components/Listbox/ScrollableList.js +65 -84
  67. package/dist/esm/components/Listbox/ScrollableList.js.map +1 -1
  68. package/dist/esm/components/Listbox/useListbox.js +53 -61
  69. package/dist/esm/components/Listbox/useListbox.js.map +1 -1
  70. package/dist/esm/components/Listbox/useMultiListbox.js +69 -96
  71. package/dist/esm/components/Listbox/useMultiListbox.js.map +1 -1
  72. package/dist/esm/components/Listbox/useTypeahead.js +10 -9
  73. package/dist/esm/components/Listbox/useTypeahead.js.map +1 -1
  74. package/dist/esm/components/Listbox/util.js +48 -85
  75. package/dist/esm/components/Listbox/util.js.map +1 -1
  76. package/dist/esm/components/Menu/Context.js +2 -2
  77. package/dist/esm/components/Menu/Context.js.map +1 -1
  78. package/dist/esm/components/Menu/Menu.js +16 -34
  79. package/dist/esm/components/Menu/Menu.js.map +1 -1
  80. package/dist/esm/components/Menu/components/Checkbox.js +9 -10
  81. package/dist/esm/components/Menu/components/Checkbox.js.map +1 -1
  82. package/dist/esm/components/Menu/components/Content.js +9 -11
  83. package/dist/esm/components/Menu/components/Content.js.map +1 -1
  84. package/dist/esm/components/Menu/components/Header.js +3 -3
  85. package/dist/esm/components/Menu/components/Header.js.map +1 -1
  86. package/dist/esm/components/Menu/components/Item.js +30 -31
  87. package/dist/esm/components/Menu/components/Item.js.map +1 -1
  88. package/dist/esm/components/Menu/components/Link.js +10 -11
  89. package/dist/esm/components/Menu/components/Link.js.map +1 -1
  90. package/dist/esm/components/Menu/components/RadioGroup.js +17 -19
  91. package/dist/esm/components/Menu/components/RadioGroup.js.map +1 -1
  92. package/dist/esm/components/Menu/components/Separator.js +1 -1
  93. package/dist/esm/components/Menu/components/Separator.js.map +1 -1
  94. package/dist/esm/components/Menu/components/Trigger.js +4 -4
  95. package/dist/esm/components/Menu/components/Trigger.js.map +1 -1
  96. package/dist/esm/components/Navigation/Navigation.js +35 -44
  97. package/dist/esm/components/Navigation/Navigation.js.map +1 -1
  98. package/dist/esm/components/Pagination/PageNumbers.js +23 -28
  99. package/dist/esm/components/Pagination/PageNumbers.js.map +1 -1
  100. package/dist/esm/components/Pagination/Pagination.js +39 -56
  101. package/dist/esm/components/Pagination/Pagination.js.map +1 -1
  102. package/dist/esm/components/Pagination/usePagination.js +7 -21
  103. package/dist/esm/components/Pagination/usePagination.js.map +1 -1
  104. package/dist/esm/components/Pagination/usePaginationShortcuts.js +13 -14
  105. package/dist/esm/components/Pagination/usePaginationShortcuts.js.map +1 -1
  106. package/dist/esm/components/Popover/Popover.js +29 -34
  107. package/dist/esm/components/Popover/Popover.js.map +1 -1
  108. package/dist/esm/components/Popover/Primitives.js +7 -8
  109. package/dist/esm/components/Popover/Primitives.js.map +1 -1
  110. package/dist/esm/components/Progress/Progress.js +11 -15
  111. package/dist/esm/components/Progress/Progress.js.map +1 -1
  112. package/dist/esm/components/Provider/Provider.js +13 -18
  113. package/dist/esm/components/Provider/Provider.js.map +1 -1
  114. package/dist/esm/components/RadioGroup/RadioGroup.js +45 -57
  115. package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -1
  116. package/dist/esm/components/SearchInput/SearchInput.js +10 -12
  117. package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
  118. package/dist/esm/components/Select/Select.js +30 -31
  119. package/dist/esm/components/Select/Select.js.map +1 -1
  120. package/dist/esm/components/Select/useSelect.js +69 -88
  121. package/dist/esm/components/Select/useSelect.js.map +1 -1
  122. package/dist/esm/components/Spinner/Spinner.js +12 -19
  123. package/dist/esm/components/Spinner/Spinner.js.map +1 -1
  124. package/dist/esm/components/Switch/Switch.js +9 -10
  125. package/dist/esm/components/Switch/Switch.js.map +1 -1
  126. package/dist/esm/components/Table/components/BaseTable.js +23 -30
  127. package/dist/esm/components/Table/components/BaseTable.js.map +1 -1
  128. package/dist/esm/components/Table/components/PaginatedTable.js +3 -7
  129. package/dist/esm/components/Table/components/PaginatedTable.js.map +1 -1
  130. package/dist/esm/components/Table/components/Table.js +18 -25
  131. package/dist/esm/components/Table/components/Table.js.map +1 -1
  132. package/dist/esm/components/Table/components/WindowedTable.js +89 -109
  133. package/dist/esm/components/Table/components/WindowedTable.js.map +1 -1
  134. package/dist/esm/components/Table/hooks/plugins/useRowActions.js +123 -148
  135. package/dist/esm/components/Table/hooks/plugins/useRowActions.js.map +1 -1
  136. package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js +57 -61
  137. package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js.map +1 -1
  138. package/dist/esm/components/Table/hooks/plugins/useRowEditing.js +39 -36
  139. package/dist/esm/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
  140. package/dist/esm/components/Table/hooks/plugins/useRowSelect.js +79 -89
  141. package/dist/esm/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
  142. package/dist/esm/components/Table/hooks/useRowCreation.js +29 -64
  143. package/dist/esm/components/Table/hooks/useRowCreation.js.map +1 -1
  144. package/dist/esm/components/Table/hooks/useTable.js +123 -141
  145. package/dist/esm/components/Table/hooks/useTable.js.map +1 -1
  146. package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js +23 -27
  147. package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js.map +1 -1
  148. package/dist/esm/components/Table/util/renderColumn.js +10 -10
  149. package/dist/esm/components/Table/util/renderColumn.js.map +1 -1
  150. package/dist/esm/components/Table/util/renderRow.js +37 -46
  151. package/dist/esm/components/Table/util/renderRow.js.map +1 -1
  152. package/dist/esm/components/Table/util/rowIndexPath.js +14 -16
  153. package/dist/esm/components/Table/util/rowIndexPath.js.map +1 -1
  154. package/dist/esm/components/Table/util/sortTypes.js +23 -31
  155. package/dist/esm/components/Table/util/sortTypes.js.map +1 -1
  156. package/dist/esm/components/Table/util.js +29 -41
  157. package/dist/esm/components/Table/util.js.map +1 -1
  158. package/dist/esm/components/Tabs/Tabs.js +25 -27
  159. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  160. package/dist/esm/components/Textarea/Textarea.js +11 -9
  161. package/dist/esm/components/Textarea/Textarea.js.map +1 -1
  162. package/dist/esm/components/Toast/Toast.js +27 -23
  163. package/dist/esm/components/Toast/Toast.js.map +1 -1
  164. package/dist/esm/components/Toast/Toaster.js +88 -118
  165. package/dist/esm/components/Toast/Toaster.js.map +1 -1
  166. package/dist/esm/components/Toast/util.js +2 -2
  167. package/dist/esm/components/Toast/util.js.map +1 -1
  168. package/dist/esm/components/Tooltip/Tooltip.js +7 -8
  169. package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
  170. package/dist/esm/components/Tour/Tour.js +46 -53
  171. package/dist/esm/components/Tour/Tour.js.map +1 -1
  172. package/dist/esm/components/Treeview/Treeview.js +26 -36
  173. package/dist/esm/components/Treeview/Treeview.js.map +1 -1
  174. package/dist/esm/components/VisuallyHidden/VisuallyHidden.js +1 -1
  175. package/dist/esm/components/VisuallyHidden/VisuallyHidden.js.map +1 -1
  176. package/dist/esm/index.css +1 -9
  177. package/dist/esm/index.js +1 -1
  178. package/dist/esm/primitives/Button.js +9 -13
  179. package/dist/esm/primitives/Button.js.map +1 -1
  180. package/dist/esm/utils/date.js +20 -40
  181. package/dist/esm/utils/date.js.map +1 -1
  182. package/dist/esm/utils/hooks/useBoundingClientRectListener.js +12 -20
  183. package/dist/esm/utils/hooks/useBoundingClientRectListener.js.map +1 -1
  184. package/dist/esm/utils/hooks/useDraggable.js +16 -17
  185. package/dist/esm/utils/hooks/useDraggable.js.map +1 -1
  186. package/dist/esm/utils/hooks/useDropTarget.js +7 -10
  187. package/dist/esm/utils/hooks/useDropTarget.js.map +1 -1
  188. package/dist/esm/utils/hooks/useListKeyboardNavigation.js +15 -30
  189. package/dist/esm/utils/hooks/useListKeyboardNavigation.js.map +1 -1
  190. package/dist/esm/utils/hooks/useListScrollTo.js +9 -9
  191. package/dist/esm/utils/hooks/useListScrollTo.js.map +1 -1
  192. package/dist/esm/utils/hooks/useOnClickOutside.js +6 -8
  193. package/dist/esm/utils/hooks/useOnClickOutside.js.map +1 -1
  194. package/dist/esm/utils/hooks/useProxiedRef.js +3 -3
  195. package/dist/esm/utils/hooks/useProxiedRef.js.map +1 -1
  196. package/dist/esm/utils/hooks/useTimer.js +9 -17
  197. package/dist/esm/utils/hooks/useTimer.js.map +1 -1
  198. package/dist/esm/utils/input.js +8 -12
  199. package/dist/esm/utils/input.js.map +1 -1
  200. package/dist/esm/utils/mergeRefs.js +2 -2
  201. package/dist/esm/utils/mergeRefs.js.map +1 -1
  202. package/dist/esm/utils/taillwind.js +2 -2
  203. package/dist/esm/utils/taillwind.js.map +1 -1
  204. package/dist/index.css +1 -9
  205. package/dist/taco.cjs.development.js +2334 -2883
  206. package/dist/taco.cjs.development.js.map +1 -1
  207. package/dist/taco.cjs.production.min.js +1 -1
  208. package/dist/taco.cjs.production.min.js.map +1 -1
  209. package/dist/utils/hooks/useListKeyboardNavigation.d.ts +1 -1
  210. package/package.json +4 -5
  211. package/types.json +10 -3
  212. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +0 -34
  213. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
@@ -1,66 +1,47 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { useRef, useState, useMemo, useEffect } from 'react';
3
2
  import { v4 } from 'uuid';
4
3
  import { useProxiedRef } from '../../utils/hooks/useProxiedRef.js';
5
- import keycode from 'keycode';
6
4
  import debounce from 'lodash-es/debounce';
7
5
  import { getId } from '../Listbox/ScrollableList.js';
8
6
  import { createCustomKeyboardEvent } from '../../utils/input.js';
9
7
  import { useFlattenedData, filterData, getIndexFromValue, setInputValueByRef, findByValue, sanitizeItem, getOptionParents } from '../Listbox/util.js';
10
8
 
11
- var _excluded = ["aria-label", "aria-labelledby", "data", "defaultValue", "disabled", "id", "inline", "loading", "onChange", "onClick", "onKeyDown", "onSearch", "readOnly", "value"];
12
- var debouncer = /*#__PURE__*/debounce(function (f) {
13
- return f();
14
- }, 200);
15
-
16
- var convertToInputValue = function convertToInputValue(value) {
17
- return String(value !== null && value !== void 0 ? value : '');
18
- };
19
-
20
- var useCombobox = function useCombobox(_ref, ref) {
21
- var ariaLabelledBy = _ref['aria-labelledby'],
22
- _ref$data = _ref.data,
23
- unfilteredData = _ref$data === void 0 ? [] : _ref$data,
24
- defaultValue = _ref.defaultValue,
25
- disabled = _ref.disabled,
26
- inline = _ref.inline,
27
- onChange = _ref.onChange,
28
- onClick = _ref.onClick,
29
- onKeyDown = _ref.onKeyDown,
30
- onSearch = _ref.onSearch,
31
- readOnly = _ref.readOnly,
32
- value = _ref.value,
33
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
34
-
35
- var inputRef = useProxiedRef(ref);
36
- var buttonRef = useRef(null);
37
- var listRef = useRef(null);
38
-
39
- var _React$useState = useState(false),
40
- open = _React$useState[0],
41
- setOpen = _React$useState[1];
42
-
43
- var listId = useMemo(function () {
44
- return v4();
45
- }, []);
46
-
47
- var _React$useState2 = useState(convertToInputValue(value)),
48
- inputValue = _React$useState2[0],
49
- setInputValue = _React$useState2[1];
50
-
51
- var shouldFilterData = !onSearch && (!inline || inline && inputValue !== convertToInputValue(value));
52
- var flattenedData = useFlattenedData(unfilteredData);
53
- var data = useMemo(function () {
54
- return shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData;
55
- }, [shouldFilterData, inputValue, flattenedData]); // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state
56
-
57
- var _React$useState3 = useState(inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined),
58
- currentIndex = _React$useState3[0],
59
- setCurrentIndex = _React$useState3[1];
60
-
61
- var setInputValueByIndex = function setInputValueByIndex(index) {
9
+ const debouncer = /*#__PURE__*/debounce(f => f(), 200);
10
+
11
+ const convertToInputValue = value => String(value !== null && value !== void 0 ? value : '');
12
+
13
+ const useCombobox = ({
14
+ 'aria-label': ariaLabel,
15
+ 'aria-labelledby': ariaLabelledBy,
16
+ data: unfilteredData = [],
17
+ defaultValue,
18
+ disabled,
19
+ id: nativeId,
20
+ inline,
21
+ loading: __,
22
+ onChange,
23
+ onClick,
24
+ onKeyDown,
25
+ onSearch,
26
+ readOnly,
27
+ value,
28
+ ...props
29
+ }, ref) => {
30
+ const inputRef = useProxiedRef(ref);
31
+ const buttonRef = useRef(null);
32
+ const listRef = useRef(null);
33
+ const [open, setOpen] = useState(false);
34
+ const listId = useMemo(() => v4(), []);
35
+ const [inputValue, setInputValue] = useState(convertToInputValue(value));
36
+ const shouldFilterData = !onSearch && (!inline || inline && inputValue !== convertToInputValue(value));
37
+ const flattenedData = useFlattenedData(unfilteredData);
38
+ const data = useMemo(() => shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData, [shouldFilterData, inputValue, flattenedData]); // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state
39
+
40
+ const [currentIndex, setCurrentIndex] = useState(inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined);
41
+
42
+ const setInputValueByIndex = index => {
62
43
  if (index !== undefined) {
63
- var option = data[index];
44
+ const option = data[index];
64
45
 
65
46
  if (option && !option.disabled) {
66
47
  setInputValueByRef(inputRef.current, option.value, 'focusout');
@@ -68,12 +49,12 @@ var useCombobox = function useCombobox(_ref, ref) {
68
49
  }
69
50
  };
70
51
 
71
- var setCurrentValue = function setCurrentValue(index) {
52
+ const setCurrentValue = index => {
72
53
  if (index === undefined) {
73
54
  return;
74
55
  }
75
56
 
76
- var option = data[index]; // if the selected option is not already selected, trigger blur event
57
+ const option = data[index]; // if the selected option is not already selected, trigger blur event
77
58
 
78
59
  if (option.value !== value) {
79
60
  setInputValueByIndex(index);
@@ -84,29 +65,29 @@ var useCombobox = function useCombobox(_ref, ref) {
84
65
  }; // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set
85
66
 
86
67
 
87
- useEffect(function () {
68
+ useEffect(() => {
88
69
  if (defaultValue && !value) {
89
70
  setInputValueByIndex(getIndexFromValue(data, defaultValue));
90
71
  }
91
72
  }, [data]); // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc
92
73
 
93
- useEffect(function () {
74
+ useEffect(() => {
94
75
  if (value !== undefined && value !== inputValue) {
95
76
  setInputValue(convertToInputValue(value));
96
77
  }
97
78
  }, [value]);
98
- useEffect(function () {
79
+ useEffect(() => {
99
80
  if (onSearch) {
100
- debouncer(function () {
81
+ debouncer(() => {
101
82
  onSearch(inputValue);
102
83
  });
103
84
  }
104
85
  }, [inputValue]); // show listbox based on input value
105
86
 
106
- useEffect(function () {
87
+ useEffect(() => {
107
88
  // don't show the popover if the internal (input) value already is the current value
108
89
  // this prevents the popover showing after selecting a value or pressing escape
109
- var isCurrentValue = value !== undefined && value !== null && inputValue === String(value);
90
+ const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);
110
91
 
111
92
  if (inputValue && data.length && !isCurrentValue) {
112
93
  setCurrentIndex(0);
@@ -118,7 +99,7 @@ var useCombobox = function useCombobox(_ref, ref) {
118
99
  setOpen(false);
119
100
  }
120
101
  }, [inputValue, data]);
121
- useEffect(function () {
102
+ useEffect(() => {
122
103
  if (open) {
123
104
  setCurrentIndex(getIndexFromValue(data, inputValue) || 0);
124
105
  } else {
@@ -126,7 +107,7 @@ var useCombobox = function useCombobox(_ref, ref) {
126
107
  }
127
108
  }, [open]); // event handlers
128
109
 
129
- var handleInputBlur = function handleInputBlur(event) {
110
+ const handleInputBlur = event => {
130
111
  event.persist();
131
112
 
132
113
  if (event.relatedTarget === listRef.current) {
@@ -135,9 +116,9 @@ var useCombobox = function useCombobox(_ref, ref) {
135
116
  }
136
117
 
137
118
  if (onChange && event.target.value !== value) {
138
- var item = findByValue(flattenedData, event.target.value);
119
+ const item = findByValue(flattenedData, event.target.value);
139
120
  event.detail = sanitizeItem(item);
140
- var parents = getOptionParents(flattenedData, item === null || item === void 0 ? void 0 : item.path);
121
+ const parents = getOptionParents(flattenedData, item === null || item === void 0 ? void 0 : item.path);
141
122
 
142
123
  if (parents !== null && parents.length > 0) {
143
124
  event.detail.parents = parents;
@@ -151,11 +132,11 @@ var useCombobox = function useCombobox(_ref, ref) {
151
132
  }
152
133
  };
153
134
 
154
- var handleInputChange = function handleInputChange(event) {
135
+ const handleInputChange = event => {
155
136
  setInputValue(event.target.value);
156
137
  };
157
138
 
158
- var handleInputClick = function handleInputClick(event) {
139
+ const handleInputClick = event => {
159
140
  if (inline || !open && inputValue && data.length) {
160
141
  setOpen(true);
161
142
  }
@@ -166,16 +147,16 @@ var useCombobox = function useCombobox(_ref, ref) {
166
147
  }
167
148
  };
168
149
 
169
- var handleInputKeyDown = function handleInputKeyDown(event) {
150
+ const handleInputKeyDown = event => {
170
151
  event.persist();
171
152
 
172
- switch (event.keyCode) {
173
- case keycode('backspace'):
153
+ switch (event.key) {
154
+ case 'Backspace':
174
155
  {
175
156
  return;
176
157
  }
177
158
 
178
- case keycode('escape'):
159
+ case 'Escape':
179
160
  {
180
161
  event.preventDefault();
181
162
  setInputValue(convertToInputValue(value));
@@ -183,10 +164,10 @@ var useCombobox = function useCombobox(_ref, ref) {
183
164
  return;
184
165
  }
185
166
 
186
- case keycode('tab'):
187
- case keycode('enter'):
167
+ case 'Tab':
168
+ case 'Enter':
188
169
  {
189
- if (event.keyCode !== keycode('tab')) {
170
+ if (event.key !== 'Tab') {
190
171
  event.preventDefault();
191
172
  }
192
173
 
@@ -195,7 +176,7 @@ var useCombobox = function useCombobox(_ref, ref) {
195
176
  return;
196
177
  }
197
178
 
198
- case keycode('down'):
179
+ case 'ArrowDown':
199
180
  if (open) {
200
181
  event.preventDefault();
201
182
  } else {
@@ -206,9 +187,9 @@ var useCombobox = function useCombobox(_ref, ref) {
206
187
 
207
188
  break;
208
189
 
209
- case keycode('up'):
210
- case keycode('home'):
211
- case keycode('end'):
190
+ case 'ArrowUp':
191
+ case 'Home':
192
+ case 'End':
212
193
  {
213
194
  if (open) {
214
195
  event.preventDefault();
@@ -224,9 +205,9 @@ var useCombobox = function useCombobox(_ref, ref) {
224
205
  }
225
206
 
226
207
  if (inline && !open) {
227
- if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {
208
+ if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
228
209
  event.preventDefault();
229
- var initialIndex = event.keyCode === keycode('up') ? data.length - 1 : 0;
210
+ const initialIndex = event.key === 'ArrowUp' ? data.length - 1 : 0;
230
211
  setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);
231
212
  setOpen(true);
232
213
  }
@@ -238,24 +219,23 @@ var useCombobox = function useCombobox(_ref, ref) {
238
219
  }
239
220
  };
240
221
 
241
- var handleListboxChange = function handleListboxChange(index) {
222
+ const handleListboxChange = index => {
242
223
  setCurrentIndex(index);
243
224
  };
244
225
 
245
- var handleListboxClick = function handleListboxClick(event, index) {
226
+ const handleListboxClick = (event, index) => {
246
227
  event.preventDefault();
247
228
  setCurrentValue(index);
248
229
  setOpen(false);
249
230
  };
250
231
 
251
- var combobox = {
232
+ const combobox = {
252
233
  'aria-expanded': open,
253
234
  'aria-owns': listId,
254
235
  'aria-haspopup': 'listbox',
255
236
  role: 'combobox'
256
237
  };
257
-
258
- var input = _extends({}, props, {
238
+ const input = { ...props,
259
239
  'aria-controls': listId,
260
240
  // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions
261
241
  // are related to the string that is present in the textbox
@@ -263,21 +243,20 @@ var useCombobox = function useCombobox(_ref, ref) {
263
243
  // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element
264
244
  'aria-activedescendant': currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,
265
245
  'aria-labelledby': ariaLabelledBy,
266
- disabled: disabled,
246
+ disabled,
267
247
  onBlur: !disabled && !readOnly ? handleInputBlur : undefined,
268
248
  onChange: !disabled && !readOnly ? handleInputChange : undefined,
269
249
  onClick: !disabled && !readOnly ? handleInputClick : undefined,
270
250
  onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,
271
- readOnly: readOnly,
251
+ readOnly,
272
252
  ref: inputRef,
273
253
  type: 'text',
274
254
  value: inputValue !== null && inputValue !== void 0 ? inputValue : ''
275
- });
276
-
277
- var list = {
255
+ };
256
+ const list = {
278
257
  'aria-labelledby': ariaLabelledBy,
279
- data: data,
280
- disabled: disabled,
258
+ data,
259
+ disabled,
281
260
  id: listId,
282
261
  onChange: handleListboxChange,
283
262
  onClick: handleListboxClick,
@@ -286,16 +265,16 @@ var useCombobox = function useCombobox(_ref, ref) {
286
265
  tabIndex: -1,
287
266
  value: currentIndex
288
267
  };
289
- var button = {
268
+ const button = {
290
269
  ref: buttonRef
291
270
  };
292
271
  return {
293
- combobox: combobox,
294
- input: input,
295
- list: list,
296
- button: button,
272
+ combobox,
273
+ input,
274
+ list,
275
+ button,
297
276
  popover: {
298
- open: open,
277
+ open,
299
278
  onOpenChange: setOpen
300
279
  }
301
280
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useCombobox.js","sources":["../../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport keycode from 'keycode';\nimport { v4 as uuid } from 'uuid';\nimport debounce from 'lodash/debounce';\nimport { ComboboxProps } from './Combobox';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '../Listbox/util';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getId, ScrollableListItemValue, ScrollableListPropsWithRef } from '../Listbox/ScrollableList';\n\nconst debouncer = debounce(f => f(), 200);\n\nconst convertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = React.HTMLAttributes<HTMLDivElement> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n button: { ref: any };\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n onSearch,\n readOnly,\n value,\n ...props\n }: Omit<ComboboxProps, 'dialog'>,\n ref: React.Ref<HTMLInputElement>\n): useCombobox => {\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => uuid(), []);\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !onSearch && (!inline || (inline && inputValue !== convertToInputValue(value)));\n const flattenedData = useFlattenedData(unfilteredData);\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined\n );\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value, 'focusout');\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n // if the selected option is not already selected, trigger blur event\n if (option.value !== value) {\n setInputValueByIndex(index);\n } else {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc\n React.useEffect(() => {\n if (value !== undefined && value !== inputValue) {\n setInputValue(convertToInputValue(value));\n }\n }, [value]);\n\n React.useEffect(() => {\n if (onSearch) {\n debouncer(() => {\n onSearch(inputValue);\n });\n }\n }, [inputValue]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n }, [inputValue, data]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n if (onChange && event.target.value !== value) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n event.persist();\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n event.persist();\n\n switch (event.keyCode) {\n case keycode('backspace'): {\n return;\n }\n\n case keycode('escape'): {\n event.preventDefault();\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case keycode('tab'):\n case keycode('enter'): {\n if (event.keyCode !== keycode('tab')) {\n event.preventDefault();\n }\n\n setCurrentValue(currentIndex);\n setOpen(false);\n return;\n }\n\n case keycode('down'):\n if (open) {\n event.preventDefault();\n } else {\n if (!inline && buttonRef.current) {\n buttonRef.current.click();\n }\n }\n break;\n\n case keycode('up'):\n case keycode('home'):\n case keycode('end'): {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (inline && !open) {\n if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {\n event.preventDefault();\n const initialIndex = event.keyCode === keycode('up') ? data.length - 1 : 0;\n setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);\n setOpen(true);\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...props,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue ?? '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n const button = {\n ref: buttonRef,\n };\n\n return {\n combobox,\n input,\n list,\n button,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":["debouncer","debounce","f","convertToInputValue","value","String","useCombobox","ref","ariaLabelledBy","data","unfilteredData","defaultValue","disabled","inline","onChange","onClick","onKeyDown","onSearch","readOnly","props","inputRef","useProxiedRef","buttonRef","React","listRef","open","setOpen","listId","uuid","inputValue","setInputValue","shouldFilterData","flattenedData","useFlattenedData","filterData","undefined","getIndexFromValue","currentIndex","setCurrentIndex","setInputValueByIndex","index","option","setInputValueByRef","current","setCurrentValue","isCurrentValue","length","handleInputBlur","event","persist","relatedTarget","preventDefault","target","item","findByValue","detail","sanitizeItem","parents","getOptionParents","path","onBlur","handleInputChange","handleInputClick","handleInputKeyDown","keyCode","keycode","click","dispatchEvent","createCustomKeyboardEvent","initialIndex","isDefaultPrevented","handleListboxChange","handleListboxClick","combobox","role","input","getId","type","list","id","scrollOnFocus","tabIndex","button","popover","onOpenChange"],"mappings":";;;;;;;;;;;AAkBA,IAAMA,SAAS,gBAAGC,QAAQ,CAAC,UAAAC,CAAC;EAAA,OAAIA,CAAC,EAAL;AAAA,CAAF,EAAW,GAAX,CAA1B;;AAEA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,KAAD;EAAA,OAAgDC,MAAM,CAACD,KAAD,aAACA,KAAD,cAACA,KAAD,GAAU,EAAV,CAAtD;AAAA,CAA5B;;IAUaE,WAAW,GAAG,SAAdA,WAAc,OAkBvBC,GAlBuB;MAGAC,sBAAnB;uBACAC;MAAMC,wCAAiB;MACvBC,oBAAAA;MACAC,gBAAAA;MAEAC,cAAAA;MAEAC,gBAAAA;MACAC,eAAAA;MACAC,iBAAAA;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L1D,IAAI,EAAJA,IADK;MAEL2D,YAAY,EAAE1D;;GAPtB;AAWH;;;;"}
1
+ {"version":3,"file":"useCombobox.js","sources":["../../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport debounce from 'lodash/debounce';\nimport { ComboboxProps } from './Combobox';\nimport {\n setInputValueByRef,\n getIndexFromValue,\n findByValue,\n useFlattenedData,\n sanitizeItem,\n getOptionParents,\n filterData,\n} from '../Listbox/util';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getId, ScrollableListItemValue, ScrollableListPropsWithRef } from '../Listbox/ScrollableList';\n\nconst debouncer = debounce(f => f(), 200);\n\nconst convertToInputValue = (value: ScrollableListItemValue | undefined) => String(value ?? '');\n\ntype useCombobox = React.HTMLAttributes<HTMLDivElement> & {\n combobox: React.HTMLAttributes<HTMLSpanElement>;\n input: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'> & { ref: React.RefObject<HTMLInputElement> };\n list: ScrollableListPropsWithRef;\n button: { ref: any };\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n};\n\nexport const useCombobox = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data: unfilteredData = [],\n defaultValue,\n disabled,\n id: nativeId,\n inline,\n loading: __,\n onChange,\n onClick,\n onKeyDown,\n onSearch,\n readOnly,\n value,\n ...props\n }: Omit<ComboboxProps, 'dialog'>,\n ref: React.Ref<HTMLInputElement>\n): useCombobox => {\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n const [open, setOpen] = React.useState(false);\n const listId = React.useMemo(() => uuid(), []);\n const [inputValue, setInputValue] = React.useState<string>(convertToInputValue(value));\n const shouldFilterData = !onSearch && (!inline || (inline && inputValue !== convertToInputValue(value)));\n const flattenedData = useFlattenedData(unfilteredData);\n const data = React.useMemo(\n () => (shouldFilterData ? filterData(flattenedData, inputValue) : flattenedData),\n [shouldFilterData, inputValue, flattenedData]\n );\n // listbox/select change value _with_ the index, but combobox changes on select of an index (click/enter), so we need state\n const [currentIndex, setCurrentIndex] = React.useState<number | undefined>(\n inputValue !== undefined ? getIndexFromValue(data, inputValue) : undefined\n );\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value, 'focusout');\n }\n }\n };\n\n const setCurrentValue = (index: number | undefined) => {\n if (index === undefined) {\n return;\n }\n\n const option = data[index];\n\n // if the selected option is not already selected, trigger blur event\n if (option.value !== value) {\n setInputValueByIndex(index);\n } else {\n // if the selected option is already selected, refill input with its value\n setInputValue(convertToInputValue(value));\n }\n };\n\n // ensure the external value is synced with the internal value when mounting, e.g. incase a default value was set\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByIndex(getIndexFromValue(data, defaultValue));\n }\n }, [data]);\n\n // update input value if it changed 'externally', e.g. clicking/entering an item in the listbox, from a modal etc\n React.useEffect(() => {\n if (value !== undefined && value !== inputValue) {\n setInputValue(convertToInputValue(value));\n }\n }, [value]);\n\n React.useEffect(() => {\n if (onSearch) {\n debouncer(() => {\n onSearch(inputValue);\n });\n }\n }, [inputValue]);\n\n // show listbox based on input value\n React.useEffect(() => {\n // don't show the popover if the internal (input) value already is the current value\n // this prevents the popover showing after selecting a value or pressing escape\n const isCurrentValue = value !== undefined && value !== null && inputValue === String(value);\n\n if (inputValue && data.length && !isCurrentValue) {\n setCurrentIndex(0);\n\n if (!open) {\n setOpen(true);\n }\n } else {\n setOpen(false);\n }\n }, [inputValue, data]);\n\n React.useEffect(() => {\n if (open) {\n setCurrentIndex(getIndexFromValue(data, inputValue) || 0);\n } else {\n setCurrentIndex(undefined);\n }\n }, [open]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (event.relatedTarget === listRef.current) {\n event.preventDefault();\n return;\n }\n\n if (onChange && event.target.value !== value) {\n const item = findByValue(flattenedData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const parents = getOptionParents(flattenedData, item?.path);\n\n if (parents !== null && parents.length > 0) {\n (event as any).detail.parents = parents;\n }\n\n onChange(event);\n }\n\n if (props.onBlur) {\n props.onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInputValue(event.target.value);\n };\n\n const handleInputClick = (event: React.MouseEvent<HTMLInputElement>): void => {\n if (inline || (!open && inputValue && data.length)) {\n setOpen(true);\n }\n\n if (onClick) {\n event.persist();\n onClick(event);\n }\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n event.persist();\n\n switch (event.key) {\n case 'Backspace': {\n return;\n }\n\n case 'Escape': {\n event.preventDefault();\n setInputValue(convertToInputValue(value));\n setOpen(false);\n return;\n }\n\n case 'Tab':\n case 'Enter': {\n if (event.key !== 'Tab') {\n event.preventDefault();\n }\n\n setCurrentValue(currentIndex);\n setOpen(false);\n return;\n }\n\n case 'ArrowDown':\n if (open) {\n event.preventDefault();\n } else {\n if (!inline && buttonRef.current) {\n buttonRef.current.click();\n }\n }\n break;\n\n case 'ArrowUp':\n case 'Home':\n case 'End': {\n if (open) {\n event.preventDefault();\n }\n break;\n }\n\n default:\n }\n\n // we aren't focused on the list, so manually forward the keydown event to it\n if (listRef.current) {\n listRef.current.dispatchEvent(createCustomKeyboardEvent(event));\n }\n\n if (inline && !open) {\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.preventDefault();\n const initialIndex = event.key === 'ArrowUp' ? data.length - 1 : 0;\n setCurrentIndex(currentIndex !== undefined ? currentIndex : initialIndex);\n setOpen(true);\n }\n }\n\n if (!event.isDefaultPrevented() && onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setCurrentIndex(index);\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n setCurrentValue(index);\n setOpen(false);\n };\n\n const combobox = {\n 'aria-expanded': open,\n 'aria-owns': listId,\n 'aria-haspopup': 'listbox' as const,\n role: 'combobox',\n };\n\n const input = {\n ...props,\n 'aria-controls': listId,\n // Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup and that the suggestions\n // are related to the string that is present in the textbox\n 'aria-autocomplete': 'list' as const,\n // Enables assistive technologies to know which element the application regards as focused while DOM focus remains on the input element\n 'aria-activedescendant':\n currentIndex !== undefined && data[currentIndex] ? getId(listId, String(data[currentIndex].value)) : undefined,\n 'aria-labelledby': ariaLabelledBy,\n disabled,\n onBlur: !disabled && !readOnly ? handleInputBlur : undefined,\n onChange: !disabled && !readOnly ? handleInputChange : undefined,\n onClick: !disabled && !readOnly ? handleInputClick : undefined,\n onKeyDown: !disabled && !readOnly ? handleInputKeyDown : undefined,\n readOnly,\n ref: inputRef,\n type: 'text',\n value: inputValue ?? '',\n };\n\n const list: ScrollableListPropsWithRef = {\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n id: listId,\n onChange: handleListboxChange,\n onClick: handleListboxClick,\n ref: listRef,\n scrollOnFocus: false,\n tabIndex: -1,\n value: currentIndex,\n };\n\n const button = {\n ref: buttonRef,\n };\n\n return {\n combobox,\n input,\n list,\n button,\n popover: {\n open,\n onOpenChange: setOpen,\n //visible: !data.length ? false : open,\n },\n };\n};\n"],"names":["debouncer","debounce","f","convertToInputValue","value","String","useCombobox","ariaLabel","ariaLabelledBy","data","unfilteredData","defaultValue","disabled","id","nativeId","inline","loading","__","onChange","onClick","onKeyDown","onSearch","readOnly","props","ref","inputRef","useProxiedRef","buttonRef","React","listRef","open","setOpen","listId","uuid","inputValue","setInputValue","shouldFilterData","flattenedData","useFlattenedData","filterData","currentIndex","setCurrentIndex","undefined","getIndexFromValue","setInputValueByIndex","index","option","setInputValueByRef","current","setCurrentValue","isCurrentValue","length","handleInputBlur","event","persist","relatedTarget","preventDefault","target","item","findByValue","detail","sanitizeItem","parents","getOptionParents","path","onBlur","handleInputChange","handleInputClick","handleInputKeyDown","key","click","dispatchEvent","createCustomKeyboardEvent","initialIndex","isDefaultPrevented","handleListboxChange","handleListboxClick","combobox","role","input","getId","type","list","scrollOnFocus","tabIndex","button","popover","onOpenChange"],"mappings":";;;;;;;;AAiBA,MAAMA,SAAS,gBAAGC,QAAQ,CAACC,CAAC,IAAIA,CAAC,EAAP,EAAW,GAAX,CAA1B;;AAEA,MAAMC,mBAAmB,GAAIC,KAAD,IAAgDC,MAAM,CAACD,KAAD,aAACA,KAAD,cAACA,KAAD,GAAU,EAAV,CAAlF;;MAUaE,WAAW,GAAG,CACvB;EACI,cAAcC,SADlB;EAEI,mBAAmBC,cAFvB;EAGIC,IAAI,EAAEC,cAAc,GAAG,EAH3B;EAIIC,YAJJ;EAKIC,QALJ;EAMIC,EAAE,EAAEC,QANR;EAOIC,MAPJ;EAQIC,OAAO,EAAEC,EARb;EASIC,QATJ;EAUIC,OAVJ;EAWIC,SAXJ;EAYIC,QAZJ;EAaIC,QAbJ;EAcIlB,KAdJ;EAeI,GAAGmB;AAfP,CADuB,EAkBvBC,GAlBuB;EAoBvB,MAAMC,QAAQ,GAAGC,aAAa,CAAmBF,GAAnB,CAA9B;EACA,MAAMG,SAAS,GAAGC,MAAA,CAAgC,IAAhC,CAAlB;EACA,MAAMC,OAAO,GAAGD,MAAA,CAA+B,IAA/B,CAAhB;EACA,MAAM,CAACE,IAAD,EAAOC,OAAP,IAAkBH,QAAA,CAAe,KAAf,CAAxB;EACA,MAAMI,MAAM,GAAGJ,OAAA,CAAc,MAAMK,EAAI,EAAxB,EAA4B,EAA5B,CAAf;EACA,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8BP,QAAA,CAAuBzB,mBAAmB,CAACC,KAAD,CAA1C,CAApC;EACA,MAAMgC,gBAA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,aAAa,EAAE,KARsB;IASrCC,QAAQ,EAAE,CAAC,CAT0B;IAUrChF,KAAK,EAAEoC;GAVX;EAaA,MAAM6C,MAAM,GAAG;IACX7D,GAAG,EAAEG;GADT;EAIA,OAAO;IACHkD,QADG;IAEHE,KAFG;IAGHG,IAHG;IAIHG,MAJG;IAKHC,OAAO,EAAE;MACLxD,IADK;MAELyD,YAAY,EAAExD;;GAPtB;AAWH;;;;"}
@@ -1,4 +1,3 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { forwardRef, createElement } from 'react';
3
2
  import cn from 'classnames';
4
3
  import { IconButton } from '../IconButton/IconButton.js';
@@ -8,23 +7,23 @@ import { Input } from '../Input/Input.js';
8
7
  import { useDatepicker } from './useDatepicker.js';
9
8
  import { Popover } from '../Popover/Popover.js';
10
9
 
11
- var _excluded = ["className", "onReset", "style", "shortcuts", "shortcutsText"];
12
- var Datepicker = /*#__PURE__*/forwardRef(function Datepicker(props, ref) {
13
- var externalClassName = props.className,
14
- handleReset = props.onReset,
15
- style = props.style,
16
- shortcuts = props.shortcuts,
17
- shortcutsText = props.shortcutsText,
18
- otherProps = _objectWithoutPropertiesLoose(props, _excluded);
19
-
20
- var _useDatepicker = useDatepicker(otherProps, ref),
21
- calendar = _useDatepicker.calendar,
22
- input = _useDatepicker.input;
23
-
24
- var _useLocalization = useLocalization(),
25
- texts = _useLocalization.texts;
26
-
27
- var className = cn('inline-flex w-full text-black font-normal', externalClassName);
10
+ const Datepicker = /*#__PURE__*/forwardRef(function Datepicker(props, ref) {
11
+ const {
12
+ className: externalClassName,
13
+ onReset: handleReset,
14
+ style,
15
+ shortcuts,
16
+ shortcutsText,
17
+ ...otherProps
18
+ } = props;
19
+ const {
20
+ calendar,
21
+ input
22
+ } = useDatepicker(otherProps, ref);
23
+ const {
24
+ texts
25
+ } = useLocalization();
26
+ const className = cn('inline-flex w-full text-black font-normal', externalClassName);
28
27
  return createElement("span", {
29
28
  className: className,
30
29
  "data-taco": "datepicker",
@@ -34,40 +33,37 @@ var Datepicker = /*#__PURE__*/forwardRef(function Datepicker(props, ref) {
34
33
  "aria-label": texts.datepicker.expand,
35
34
  disabled: input.disabled || input.readOnly,
36
35
  icon: "calendar"
37
- })), createElement(Popover.Content, null, function (_ref) {
38
- var close = _ref.close;
39
- return createElement("div", {
40
- className: "-m-3 flex"
41
- }, createElement(Calendar, Object.assign({}, calendar, {
42
- onChange: function onChange(date, event) {
43
- calendar.onChange(date, event);
44
- close();
45
- },
46
- tabIndex: -1
47
- })), shortcuts && createElement("div", {
48
- className: "border-grey-dark flex flex-col border-l"
49
- }, createElement("span", {
50
- className: "m-4 mb-3 flex h-8 w-32 items-center text-xs font-semibold"
51
- }, shortcutsText !== null && shortcutsText !== void 0 ? shortcutsText : texts.datepicker.shortcuts), createElement("ul", null, shortcuts.map(function (shortcut, i) {
52
- return createElement("li", {
53
- key: i
54
- }, createElement("button", {
55
- className: "hover:bg-grey-light flex w-full items-start px-4 py-1 text-xs",
56
- onClick: function onClick(event) {
57
- event.persist();
58
- shortcut.onClick(event);
59
- close();
60
- }
61
- }, shortcut.text));
62
- })), handleReset && createElement("button", {
63
- className: "text-blue hover:text-blue-light my-4 mx-auto mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs",
64
- onClick: function onClick(event) {
65
- event.persist();
66
- handleReset(event);
67
- close();
68
- }
69
- }, texts.datepicker.clear)));
70
- }))
36
+ })), createElement(Popover.Content, null, ({
37
+ close
38
+ }) => createElement("div", {
39
+ className: "-m-3 flex"
40
+ }, createElement(Calendar, Object.assign({}, calendar, {
41
+ onChange: (date, event) => {
42
+ calendar.onChange(date, event);
43
+ close();
44
+ },
45
+ tabIndex: -1
46
+ })), shortcuts && createElement("div", {
47
+ className: "border-grey-dark flex flex-col border-l"
48
+ }, createElement("span", {
49
+ className: "m-4 mb-3 flex h-8 w-32 items-center text-xs font-semibold"
50
+ }, shortcutsText !== null && shortcutsText !== void 0 ? shortcutsText : texts.datepicker.shortcuts), createElement("ul", null, shortcuts.map((shortcut, i) => createElement("li", {
51
+ key: i
52
+ }, createElement("button", {
53
+ className: "hover:bg-grey-light flex w-full items-start px-4 py-1 text-xs",
54
+ onClick: event => {
55
+ event.persist();
56
+ shortcut.onClick(event);
57
+ close();
58
+ }
59
+ }, shortcut.text)))), handleReset && createElement("button", {
60
+ className: "text-blue hover:text-blue-light my-4 mx-auto mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs",
61
+ onClick: event => {
62
+ event.persist();
63
+ handleReset(event);
64
+ close();
65
+ }
66
+ }, texts.datepicker.clear)))))
71
67
  })));
72
68
  });
73
69
 
@@ -1 +1 @@
1
- {"version":3,"file":"Datepicker.js","sources":["../../../../src/components/Datepicker/Datepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Calendar, CalendarProps } from '../Calendar/Calendar';\nimport { Input, InputProps } from '../Input/Input';\nimport { useLocalization } from '../Provider/Provider';\nimport { useDatepicker } from './useDatepicker';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Popover } from '../Popover/Popover';\n\nexport type DatepickerTexts = {\n /** Aria-label for calendar */\n calendar: string;\n /** Clear button text */\n clear: string;\n /**\n * Aria-label for calendar icon button in the input.\n * Calendar will open when user clicks this icon button.\n */\n expand: string;\n /** Shortcut heading text */\n shortcuts: string;\n};\n\nexport type DatepickerProps = Omit<InputProps, 'value'> & {\n /** [Calendar](component:calendar) component associated with the DatePicker */\n calendar?: CalendarProps;\n /** List of shortcuts */\n shortcuts?: any;\n /** Title for the shortcuts panel */\n shortcutsText?: string;\n /** Handler to be called when the clear button is clicked */\n onReset?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /**\n * Date value of the calendar.\n * This will be displayed in DatePicker's input in the format given to the [Provider](component:provider) component\n */\n value?: Date;\n};\n\nexport const Datepicker = React.forwardRef(function Datepicker(props: DatepickerProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, onReset: handleReset, style, shortcuts, shortcutsText, ...otherProps } = props;\n const { calendar, input } = useDatepicker(otherProps, ref);\n const { texts } = useLocalization();\n const className = cn('inline-flex w-full text-black font-normal', externalClassName);\n\n return (\n <span className={className} data-taco=\"datepicker\" style={style}>\n <Input\n {...input}\n button={\n <Popover>\n <Popover.Trigger>\n <IconButton\n aria-label={texts.datepicker.expand}\n disabled={input.disabled || input.readOnly}\n icon=\"calendar\"\n />\n </Popover.Trigger>\n <Popover.Content>\n {({ close }) => (\n <div className=\"-m-3 flex\">\n <Calendar\n {...calendar}\n onChange={(date: Date, event?: React.MouseEvent<HTMLDivElement>) => {\n calendar.onChange(date, event);\n close();\n }}\n tabIndex={-1}\n />\n {shortcuts && (\n <div className=\"border-grey-dark flex flex-col border-l\">\n <span className=\"m-4 mb-3 flex h-8 w-32 items-center text-xs font-semibold\">\n {shortcutsText ?? texts.datepicker.shortcuts}\n </span>\n <ul>\n {shortcuts.map((shortcut, i) => (\n <li key={i}>\n <button\n className=\"hover:bg-grey-light flex w-full items-start px-4 py-1 text-xs\"\n onClick={event => {\n event.persist();\n shortcut.onClick(event);\n close();\n }}\n >\n {shortcut.text}\n </button>\n </li>\n ))}\n </ul>\n {handleReset && (\n <button\n className=\"text-blue hover:text-blue-light my-4 mx-auto mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs\"\n onClick={event => {\n event.persist();\n handleReset(event);\n close();\n }}\n >\n {texts.datepicker.clear}\n </button>\n )}\n </div>\n )}\n </div>\n )}\n </Popover.Content>\n </Popover>\n }\n />\n </span>\n );\n});\n"],"names":["Datepicker","React","props","ref","externalClassName","className","handleReset","onReset","style","shortcuts","shortcutsText","otherProps","useDatepicker","calendar","input","useLocalization","texts","cn","Input","button","Popover","Trigger","IconButton","datepicker","expand","disabled","readOnly","icon","Content","close","Calendar","onChange","date","event","tabIndex","map","shortcut","i","key","onClick","persist","text","clear"],"mappings":";;;;;;;;;;;IAuCaA,UAAU,gBAAGC,UAAA,CAA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,CAAC;QANf,CADJ,EASKzB,SAAS,IACNR,aAAA,MAAA;QAAKI,SAAS,EAAC;OAAf,EACIJ,aAAA,OAAA;QAAMI,SAAS,EAAC;OAAhB,EACKK,aADL,aACKA,aADL,cACKA,aADL,GACsBM,KAAK,CAACO,UAAN,CAAiBd,SADvC,CADJ,EAIIR,aAAA,KAAA,MAAA,EACKQ,SAAS,CAAC0B,GAAV,CAAc,UAACC,QAAD,EAAWC,CAAX;QAAA,OACXpC,aAAA,KAAA;UAAIqC,GAAG,EAAED;SAAT,EACIpC,aAAA,SAAA;UACII,SAAS,EAAC;UACVkC,OAAO,EAAE,iBAAAN,KAAK;YACVA,KAAK,CAACO,OAAN;YACAJ,QAAQ,CAACG,OAAT,CAAiBN,KAAjB;YACAJ,KAAK;;SALb,EAQKO,QAAQ,CAACK,IARd,CADJ,CADW;OAAd,CADL,CAJJ,EAoBKnC,WAAW,IACRL,aAAA,SAAA;QACII,SAAS,EAAC;QACVkC,OAAO,EAAE,iBAAAN,KAAK;UACVA,KAAK,CAACO,OAAN;UACAlC,WAAW,CAAC2B,KAAD,CAAX;UACAJ,KAAK;;OALb,EAQKb,KAAK,CAACO,UAAN,CAAiBmB,KARtB,CArBR,CAVR,CADH;KADL,CARJ;IAHR,CADJ,CADJ;AAmEH,CAzEyB;;;;"}
1
+ {"version":3,"file":"Datepicker.js","sources":["../../../../src/components/Datepicker/Datepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Calendar, CalendarProps } from '../Calendar/Calendar';\nimport { Input, InputProps } from '../Input/Input';\nimport { useLocalization } from '../Provider/Provider';\nimport { useDatepicker } from './useDatepicker';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Popover } from '../Popover/Popover';\n\nexport type DatepickerTexts = {\n /** Aria-label for calendar */\n calendar: string;\n /** Clear button text */\n clear: string;\n /**\n * Aria-label for calendar icon button in the input.\n * Calendar will open when user clicks this icon button.\n */\n expand: string;\n /** Shortcut heading text */\n shortcuts: string;\n};\n\nexport type DatepickerProps = Omit<InputProps, 'value'> & {\n /** [Calendar](component:calendar) component associated with the DatePicker */\n calendar?: CalendarProps;\n /** List of shortcuts */\n shortcuts?: any;\n /** Title for the shortcuts panel */\n shortcutsText?: string;\n /** Handler to be called when the clear button is clicked */\n onReset?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /**\n * Date value of the calendar.\n * This will be displayed in DatePicker's input in the format given to the [Provider](component:provider) component\n */\n value?: Date;\n};\n\nexport const Datepicker = React.forwardRef(function Datepicker(props: DatepickerProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, onReset: handleReset, style, shortcuts, shortcutsText, ...otherProps } = props;\n const { calendar, input } = useDatepicker(otherProps, ref);\n const { texts } = useLocalization();\n const className = cn('inline-flex w-full text-black font-normal', externalClassName);\n\n return (\n <span className={className} data-taco=\"datepicker\" style={style}>\n <Input\n {...input}\n button={\n <Popover>\n <Popover.Trigger>\n <IconButton\n aria-label={texts.datepicker.expand}\n disabled={input.disabled || input.readOnly}\n icon=\"calendar\"\n />\n </Popover.Trigger>\n <Popover.Content>\n {({ close }) => (\n <div className=\"-m-3 flex\">\n <Calendar\n {...calendar}\n onChange={(date: Date, event?: React.MouseEvent<HTMLDivElement>) => {\n calendar.onChange(date, event);\n close();\n }}\n tabIndex={-1}\n />\n {shortcuts && (\n <div className=\"border-grey-dark flex flex-col border-l\">\n <span className=\"m-4 mb-3 flex h-8 w-32 items-center text-xs font-semibold\">\n {shortcutsText ?? texts.datepicker.shortcuts}\n </span>\n <ul>\n {shortcuts.map((shortcut, i) => (\n <li key={i}>\n <button\n className=\"hover:bg-grey-light flex w-full items-start px-4 py-1 text-xs\"\n onClick={event => {\n event.persist();\n shortcut.onClick(event);\n close();\n }}\n >\n {shortcut.text}\n </button>\n </li>\n ))}\n </ul>\n {handleReset && (\n <button\n className=\"text-blue hover:text-blue-light my-4 mx-auto mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs\"\n onClick={event => {\n event.persist();\n handleReset(event);\n close();\n }}\n >\n {texts.datepicker.clear}\n </button>\n )}\n </div>\n )}\n </div>\n )}\n </Popover.Content>\n </Popover>\n }\n />\n </span>\n );\n});\n"],"names":["Datepicker","React","props","ref","className","externalClassName","onReset","handleReset","style","shortcuts","shortcutsText","otherProps","calendar","input","useDatepicker","texts","useLocalization","cn","Input","button","Popover","Trigger","IconButton","datepicker","expand","disabled","readOnly","icon","Content","close","Calendar","onChange","date","event","tabIndex","map","shortcut","i","key","onClick","persist","text","clear"],"mappings":";;;;;;;;;MAuCaA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;EACvC,MAAM;IAAEC,SAAS,EAAEC,iBAAb;IAAgCC,OAAO,EAAEC,WAAzC;IAAsDC,KAAtD;IAA6DC,SAA7D;IAAwEC,aAAxE;IAAuF,GAAGC;MAAeT,KAA/G;EACA,MAAM;IAAEU,QAAF;IAAYC;MAAUC,aAAa,CAACH,UAAD,EAAaR,GAAb,CAAzC;EACA,MAAM;IAAEY;MAAUC,eAAe,EAAjC;EACA,MAAMZ,SAAS,GAAGa,EAAE,CAAC,2CAAD,EAA8CZ,iBAA9C,CAApB;EAEA,OACIJ,aAAA,OAAA;IAAMG,SAAS,EAAEA;iBAAqB;IAAaI,KAAK,EAAEA;GAA1D,EACIP,aAAA,CAACiB,KAAD,oBACQL;IACJM,MAAM,EACFlB,aAAA,CAACmB,OAAD,MAAA,EACInB,aAAA,CAACmB,OAAO,CAACC,OAAT,MAAA,EACIpB,aAAA,CAACqB,UAAD;oBACgBP,KAAK,CAACQ,UAAN,CAAiBC;MAC7BC,QAAQ,EAAEZ,KAAK,CAACY,QAAN,IAAkBZ,KAAK,CAACa;MAClCC,IAAI,EAAC;KAHT,CADJ,CADJ,EAQI1B,aAAA,CAACmB,OAAO,CAACQ,OAAT,MAAA,EACK,CAAC;MAAEC;KAAH,KACG5B,aAAA,MAAA;MAAKG,SAAS,EAAC;KAAf,EACI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