@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,17 +1,15 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { forwardRef, createElement } from 'react';
3
2
  import cn from 'classnames';
4
3
  import { Icon } from '../Icon/Icon.js';
5
4
  import { getButtonClasses, getAppearanceClasses, createButton } from '../Button/util.js';
6
5
 
7
- var _excluded = ["icon", "rounded"];
8
- var IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
9
- var icon = props.icon,
10
- _props$rounded = props.rounded,
11
- rounded = _props$rounded === void 0 ? false : _props$rounded,
12
- otherProps = _objectWithoutPropertiesLoose(props, _excluded);
13
-
14
- var className = cn('w-8', getButtonClasses(), getAppearanceClasses(otherProps.appearance, true), {
6
+ const IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
7
+ const {
8
+ icon,
9
+ rounded = false,
10
+ ...otherProps
11
+ } = props;
12
+ const className = cn('w-8', getButtonClasses(), getAppearanceClasses(otherProps.appearance, true), {
15
13
  'rounded-full': rounded,
16
14
  rounded: !rounded,
17
15
  'cursor-not-allowed opacity-50': props.disabled,
@@ -22,13 +20,13 @@ var IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
22
20
  return null;
23
21
  }
24
22
 
25
- return createButton(_extends({}, otherProps, {
23
+ return createButton({ ...otherProps,
26
24
  children: createElement(Icon, {
27
25
  name: icon,
28
26
  className: "m-0 p-0"
29
27
  }),
30
28
  'data-taco': 'icon-button'
31
- }), className, ref);
29
+ }, className, ref);
32
30
  });
33
31
 
34
32
  export { IconButton };
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","sources":["../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getAppearanceClasses, getButtonClasses, createButton } from '../Button/util';\nimport { Appearance } from '../../types';\nimport { DialogProps, HangerProps, MenuProps, PopoverProps } from '../..';\n\nexport type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'children'> & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Set which icon should be rendered within button */\n icon: IconName; // this dynamic type causes the type extraction for props to fail\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /**\n * Set whether the button is rounded.\n * Default value is `false`\n */\n rounded?: boolean;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const IconButton = React.forwardRef(function IconButton(props: IconButtonProps, ref: React.Ref<HTMLButtonElement>) {\n const { icon, rounded = false, ...otherProps } = props;\n\n const className = cn(\n 'w-8',\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance, true),\n {\n 'rounded-full': rounded,\n rounded: !rounded,\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n },\n props.className\n );\n\n if (!icon) {\n return null;\n }\n\n return createButton(\n { ...otherProps, children: <Icon name={icon} className=\"m-0 p-0\" />, 'data-taco': 'icon-button' },\n className,\n ref\n );\n});\n"],"names":["IconButton","React","props","ref","icon","rounded","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","createButton","children","Icon","name"],"mappings":";;;;;;;IAsCaA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;EACvC,IAAQC,IAAR,GAAiDF,KAAjD,CAAQE,IAAR;uBAAiDF,KAAjD,CAAcG,OAAd;MAAcA,OAAd,+BAAwB,KAAxB;MAAkCC,UAAlC,iCAAiDJ,KAAjD;;EAEA,IAAMK,SAAS,GAAGC,EAAE,CAChB,KADgB,EAEhBC,gBAAgB,EAFA,EAGhBC,oBAAoB,CAACJ,UAAU,CAACK,UAAZ,EAAwB,IAAxB,CAHJ,EAIhB;IACI,gBAAgBN,OADpB;IAEIA,OAAO,EAAE,CAACA,OAFd;IAGI,iCAAiCH,KAAK,CAACU,QAH3C;IAII,wCAAwC,CAACV,KAAK,CAACU;GARnC,EAUhBV,KAAK,CAACK,SAVU,CAApB;;EAaA,IAAI,CAACH,IAAL,EAAW;IACP,OAAO,IAAP;;;EAGJ,OAAOS,YAAY,cACVP,UADU;IACEQ,QAAQ,EAAEb,aAAA,CAACc,IAAD;MAAMC,IAAI,EAAEZ;MAAMG,SAAS,EAAC;KAA5B,CADZ;IACsD,aAAa;MAClFA,SAFe,EAGfJ,GAHe,CAAnB;AAKH,CAzByB;;;;"}
1
+ {"version":3,"file":"IconButton.js","sources":["../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getAppearanceClasses, getButtonClasses, createButton } from '../Button/util';\nimport { Appearance } from '../../types';\nimport { DialogProps, HangerProps, MenuProps, PopoverProps } from '../..';\n\nexport type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'children'> & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Set which icon should be rendered within button */\n icon: IconName; // this dynamic type causes the type extraction for props to fail\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /**\n * Set whether the button is rounded.\n * Default value is `false`\n */\n rounded?: boolean;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const IconButton = React.forwardRef(function IconButton(props: IconButtonProps, ref: React.Ref<HTMLButtonElement>) {\n const { icon, rounded = false, ...otherProps } = props;\n\n const className = cn(\n 'w-8',\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance, true),\n {\n 'rounded-full': rounded,\n rounded: !rounded,\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n },\n props.className\n );\n\n if (!icon) {\n return null;\n }\n\n return createButton(\n { ...otherProps, children: <Icon name={icon} className=\"m-0 p-0\" />, 'data-taco': 'icon-button' },\n className,\n ref\n );\n});\n"],"names":["IconButton","React","props","ref","icon","rounded","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","createButton","children","Icon","name"],"mappings":";;;;;MAsCaA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;EACvC,MAAM;IAAEC,IAAF;IAAQC,OAAO,GAAG,KAAlB;IAAyB,GAAGC;MAAeJ,KAAjD;EAEA,MAAMK,SAAS,GAAGC,EAAE,CAChB,KADgB,EAEhBC,gBAAgB,EAFA,EAGhBC,oBAAoB,CAACJ,UAAU,CAACK,UAAZ,EAAwB,IAAxB,CAHJ,EAIhB;IACI,gBAAgBN,OADpB;IAEIA,OAAO,EAAE,CAACA,OAFd;IAGI,iCAAiCH,KAAK,CAACU,QAH3C;IAII,wCAAwC,CAACV,KAAK,CAACU;GARnC,EAUhBV,KAAK,CAACK,SAVU,CAApB;;EAaA,IAAI,CAACH,IAAL,EAAW;IACP,OAAO,IAAP;;;EAGJ,OAAOS,YAAY,CACf,EAAE,GAAGP,UAAL;IAAiBQ,QAAQ,EAAEb,aAAA,CAACc,IAAD;MAAMC,IAAI,EAAEZ;MAAMG,SAAS,EAAC;KAA5B,CAA3B;IAAqE,aAAa;GADnE,EAEfA,SAFe,EAGfJ,GAHe,CAAnB;AAKH,CAzByB;;;;"}
@@ -1,25 +1,25 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { forwardRef, useEffect, createElement, cloneElement } from 'react';
3
2
  import cn from 'classnames';
4
3
  import { Icon } from '../Icon/Icon.js';
5
4
  import { useProxiedRef } from '../../utils/hooks/useProxiedRef.js';
6
5
  import { getInputClasses, getButtonStateClasses } from './util.js';
7
6
 
8
- var _excluded = ["button", "icon", "highlighted", "invalid", "onKeyDown", "autoFocus"];
9
- var Input = /*#__PURE__*/forwardRef(function Input(props, ref) {
10
- var button = props.button,
11
- icon = props.icon,
12
- invalid = props.invalid,
13
- onKeyDown = props.onKeyDown,
14
- autoFocus = props.autoFocus,
15
- otherProps = _objectWithoutPropertiesLoose(props, _excluded);
16
-
17
- var inputRef = useProxiedRef(ref);
18
- var hasContainer = button || icon;
19
- var className = cn(getInputClasses(props), 'min-h-[theme(spacing.8)] pointer-events-all', {
7
+ const Input = /*#__PURE__*/forwardRef(function Input(props, ref) {
8
+ const {
9
+ button,
10
+ icon,
11
+ highlighted,
12
+ invalid,
13
+ onKeyDown,
14
+ autoFocus,
15
+ ...otherProps
16
+ } = props;
17
+ const inputRef = useProxiedRef(ref);
18
+ const hasContainer = button || icon;
19
+ const className = cn(getInputClasses(props), 'min-h-[theme(spacing.8)] pointer-events-all', {
20
20
  'pr-8': !!hasContainer
21
21
  }, !hasContainer && otherProps.className);
22
- useEffect(function () {
22
+ useEffect(() => {
23
23
  if (autoFocus && inputRef.current) {
24
24
  inputRef.current.focus();
25
25
  }
@@ -27,10 +27,10 @@ var Input = /*#__PURE__*/forwardRef(function Input(props, ref) {
27
27
  // if it has scroll height then the browser reverts to native scrolling behaviour only
28
28
  // so we manually override it to ensure _our_ desired behaviour remains intact
29
29
 
30
- var handleKeyDown = function handleKeyDown(event) {
30
+ const handleKeyDown = event => {
31
31
  if (!event.shiftKey && (event.key === 'Home' || event.key === 'End')) {
32
32
  event.preventDefault();
33
- var position = event.key === 'End' ? event.currentTarget.value.length : 0;
33
+ const position = event.key === 'End' ? event.currentTarget.value.length : 0;
34
34
  event.currentTarget.setSelectionRange(position, position);
35
35
  }
36
36
 
@@ -39,7 +39,7 @@ var Input = /*#__PURE__*/forwardRef(function Input(props, ref) {
39
39
  }
40
40
  };
41
41
 
42
- var input = createElement("input", Object.assign({}, otherProps, {
42
+ const input = createElement("input", Object.assign({}, otherProps, {
43
43
  className: className,
44
44
  "data-taco": "input",
45
45
  onKeyDown: handleKeyDown,
@@ -47,19 +47,19 @@ var Input = /*#__PURE__*/forwardRef(function Input(props, ref) {
47
47
  }));
48
48
 
49
49
  if (hasContainer) {
50
- var extra;
50
+ let extra;
51
51
 
52
52
  if (button) {
53
- var _cn;
54
-
55
- var disabled = button.props.disabled || otherProps.disabled;
56
- var buttonClassName = cn('items-center flex justify-center border absolute rounded-l-none rounded-r right-0 h-full focus:rounded focus:outline-none', (_cn = {}, _cn[getButtonStateClasses(invalid)] = !props.disabled, _cn), button.props.className);
53
+ const disabled = button.props.disabled || otherProps.disabled;
54
+ const buttonClassName = cn('items-center flex justify-center border absolute rounded-l-none rounded-r right-0 h-full focus:rounded focus:outline-none', {
55
+ [getButtonStateClasses(invalid)]: !props.disabled
56
+ }, button.props.className);
57
57
  extra = cloneElement(button, {
58
58
  className: buttonClassName,
59
- disabled: disabled
59
+ disabled
60
60
  });
61
61
  } else if (icon) {
62
- var iconClassName = cn('items-center flex justify-center absolute pointer-events-none mr-1 p-px right-0 w-5 top-1/2 -translate-y-1/2', {
62
+ const iconClassName = cn('items-center flex justify-center absolute pointer-events-none mr-1 p-px right-0 w-5 top-1/2 -translate-y-1/2', {
63
63
  'text-grey-dark': props.disabled,
64
64
  'text-grey-darkest': !props.disabled
65
65
  });
@@ -71,7 +71,7 @@ var Input = /*#__PURE__*/forwardRef(function Input(props, ref) {
71
71
  });
72
72
  }
73
73
 
74
- var containerClassName = cn('bg-white inline-flex relative rounded w-full', otherProps.className);
74
+ const containerClassName = cn('bg-white inline-flex relative rounded w-full', otherProps.className);
75
75
  return createElement("div", {
76
76
  className: containerClassName,
77
77
  "data-taco": "input-container"
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getButtonStateClasses, getInputClasses } from './util';\n\nexport type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {\n /** Shows a button within the input field */\n button?: React.ReactElement;\n /** Shows an icon within the input field */\n icon?: IconName | JSX.Element;\n /** Draws attention to the input by changing its style and making it visually prominent */\n highlighted?: boolean;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n};\n\nexport const Input = React.forwardRef(function Input(props: InputProps, ref: React.Ref<HTMLInputElement>) {\n const { button, icon, highlighted, invalid, onKeyDown, autoFocus, ...otherProps } = props;\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const hasContainer = button || icon;\n const className = cn(\n getInputClasses(props),\n 'min-h-[theme(spacing.8)] pointer-events-all',\n {\n 'pr-8': !!hasContainer,\n },\n !hasContainer && otherProps.className\n );\n\n React.useEffect(() => {\n if (autoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, []);\n\n // home and end keys only navigate to the start/end of input value if the input container does not scroll\n // if it has scroll height then the browser reverts to native scrolling behaviour only\n // so we manually override it to ensure _our_ desired behaviour remains intact\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (!event.shiftKey && (event.key === 'Home' || event.key === 'End')) {\n event.preventDefault();\n const position = event.key === 'End' ? event.currentTarget.value.length : 0;\n event.currentTarget.setSelectionRange(position, position);\n }\n\n if (onKeyDown) {\n onKeyDown(event);\n }\n };\n\n const input = <input {...otherProps} className={className} data-taco=\"input\" onKeyDown={handleKeyDown} ref={inputRef} />;\n\n if (hasContainer) {\n let extra: any;\n\n if (button) {\n const disabled = button.props.disabled || otherProps.disabled;\n const buttonClassName = cn(\n 'items-center flex justify-center border absolute rounded-l-none rounded-r right-0 h-full focus:rounded focus:outline-none',\n {\n [getButtonStateClasses(invalid)]: !props.disabled,\n },\n button.props.className\n );\n extra = React.cloneElement(button, {\n className: buttonClassName,\n disabled,\n });\n } else if (icon) {\n const iconClassName = cn(\n 'items-center flex justify-center absolute pointer-events-none mr-1 p-px right-0 w-5 top-1/2 -translate-y-1/2',\n {\n 'text-grey-dark': props.disabled,\n 'text-grey-darkest': !props.disabled,\n }\n );\n extra =\n typeof icon === 'string' ? (\n <Icon className={iconClassName} name={icon} />\n ) : (\n React.cloneElement(icon, { className: cn(iconClassName, icon.props.className) })\n );\n }\n\n const containerClassName = cn('bg-white inline-flex relative rounded w-full', otherProps.className);\n\n return (\n <div className={containerClassName} data-taco=\"input-container\">\n {input}\n {extra}\n </div>\n );\n }\n\n return input;\n});\n"],"names":["Input","React","props","ref","button","icon","invalid","onKeyDown","autoFocus","otherProps","inputRef","useProxiedRef","hasContainer","className","cn","getInputClasses","current","focus","handleKeyDown","event","shiftKey","key","preventDefault","position","currentTarget","value","length","setSelectionRange","input","extra","disabled","buttonClassName","getButtonStateClasses","iconClassName","Icon","name","containerClassName"],"mappings":";;;;;;;;IAiBaA,KAAK,gBAAGC,UAAA,CAAiB,SAASD,KAAT,CAAeE,KAAf,EAAkCC,GAAlC;MAC1BC,MAAR,GAAoFF,KAApF,CAAQE,MAAR;MAAgBC,IAAhB,GAAoFH,KAApF,CAAgBG,IAAhB;MAAmCC,OAAnC,GAAoFJ,KAApF,CAAmCI,OAAnC;MAA4CC,SAA5C,GAAoFL,KAApF,CAA4CK,SAA5C;MAAuDC,SAAvD,GAAoFN,KAApF,CAAuDM,SAAvD;MAAqEC,UAArE,iCAAoFP,KAApF;;EACA,IAAMQ,QAAQ,GAAGC,aAAa,CAAmBR,GAAnB,CAA9B;EACA,IAAMS,YAAY,GAAGR,MAAM,IAAIC,IAA/B;EACA,IAAMQ,SAAS,GAAGC,EAAE,CAChBC,eAAe,CAACb,KAAD,CADC,EAEhB,6CAFgB,EAGhB;IACI,QAAQ,CAAC,CAACU;GAJE,EAMhB,CAACA,YAAD,IAAiBH,UAAU,CAACI,SANZ,CAApB;EASAZ,SAAA,CAAgB;IACZ,IAAIO,SAAS,IAAIE,QAAQ,CAACM,OAA1B,EAAmC;MAC/BN,QAAQ,CAACM,OAAT,CAAiBC,KAAjB;;GAFR,EAIG,EAJH;;;;EASA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD;IAClB,IAAI,CAACA,KAAK,CAACC,QAAP,KAAoBD,KAAK,CAACE,GAAN,KAAc,MAAd,IAAwBF,KAAK,CAACE,GAAN,KAAc,KAA1D,CAAJ,EAAsE;MAClEF,KAAK,CAACG,cAAN;MACA,IAAMC,QAAQ,GAAGJ,KAAK,CAACE,GAAN,KAAc,KAAd,GAAsBF,KAAK,CAACK,aAAN,CAAoBC,KAApB,CAA0BC,MAAhD,GAAyD,CAA1E;MACAP,KAAK,CAACK,aAAN,CAAoBG,iBAApB,CAAsCJ,QAAtC,EAAgDA,QAAhD;;;IAGJ,IAAIhB,SAAJ,EAAe;MACXA,SAAS,CAACY,KAAD,CAAT;;GARR;;EAYA,IAAMS,KAAK,GAAG3B,aAAA,QAAA,oBAAWQ;IAAYI,SAAS,EAAEA;iBAAqB;IAAQN,SAAS,EAAEW;IAAef,GAAG,EAAEO;IAA9F,CAAd;;EAEA,IAAIE,YAAJ,EAAkB;IACd,IAAIiB,KAAJ;;IAEA,IAAIzB,MAAJ,EAAY;MAAA;;MACR,IAAM0B,QAAQ,GAAG1B,MAAM,CAACF,KAAP,CAAa4B,QAAb,IAAyBrB,UAAU,CAACqB,QAArD;MACA,IAAMC,eAAe,GAAGjB,EAAE,CACtB,2HADsB,iBAGjBkB,qBAAqB,CAAC1B,OAAD,CAHJ,IAGgB,CAACJ,KAAK,CAAC4B,QAHvB,QAKtB1B,MAAM,CAACF,KAAP,CAAaW,SALS,CAA1B;MAOAgB,KAAK,GAAG5B,YAAA,CAAmBG,MAAnB,EAA2B;QAC/BS,SAAS,EAAEkB,eADoB;QAE/BD,QAAQ,EAARA;OAFI,CAAR;KATJ,MAaO,IAAIzB,IAAJ,EAAU;MACb,IAAM4B,aAAa,GAAGnB,EAAE,CACpB,8GADoB,EAEpB;QACI,kBAAkBZ,KAAK,CAAC4B,QAD5B;QAEI,qBAAqB,CAAC5B,KAAK,CAAC4B;OAJZ,CAAxB;MAOAD,KAAK,GACD,OAAOxB,IAAP,KAAgB,QAAhB,GACIJ,aAAA,CAACiC,IAAD;QAAMrB,SAAS,EAAEoB;QAAeE,IAAI,EAAE9B;OAAtC,CADJ,GAGIJ,YAAA,CAAmBI,IAAnB,EAAyB;QAAEQ,SAAS,EAAEC,EAAE,CAACmB,aAAD,EAAgB5B,IAAI,CAACH,KAAL,CAAWW,SAA3B;OAAxC,CAJR;;;IAQJ,IAAMuB,kBAAkB,GAAGtB,EAAE,CAAC,8CAAD,EAAiDL,UAAU,CAACI,SAA5D,CAA7B;IAEA,OACIZ,aAAA,MAAA;MAAKY,SAAS,EAAEuB;mBAA8B;KAA9C,EACKR,KADL,EAEKC,KAFL,CADJ;;;EAQJ,OAAOD,KAAP;AACH,CA/EoB;;;;"}
1
+ {"version":3,"file":"Input.js","sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getButtonStateClasses, getInputClasses } from './util';\n\nexport type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {\n /** Shows a button within the input field */\n button?: React.ReactElement;\n /** Shows an icon within the input field */\n icon?: IconName | JSX.Element;\n /** Draws attention to the input by changing its style and making it visually prominent */\n highlighted?: boolean;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n};\n\nexport const Input = React.forwardRef(function Input(props: InputProps, ref: React.Ref<HTMLInputElement>) {\n const { button, icon, highlighted, invalid, onKeyDown, autoFocus, ...otherProps } = props;\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const hasContainer = button || icon;\n const className = cn(\n getInputClasses(props),\n 'min-h-[theme(spacing.8)] pointer-events-all',\n {\n 'pr-8': !!hasContainer,\n },\n !hasContainer && otherProps.className\n );\n\n React.useEffect(() => {\n if (autoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, []);\n\n // home and end keys only navigate to the start/end of input value if the input container does not scroll\n // if it has scroll height then the browser reverts to native scrolling behaviour only\n // so we manually override it to ensure _our_ desired behaviour remains intact\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (!event.shiftKey && (event.key === 'Home' || event.key === 'End')) {\n event.preventDefault();\n const position = event.key === 'End' ? event.currentTarget.value.length : 0;\n event.currentTarget.setSelectionRange(position, position);\n }\n\n if (onKeyDown) {\n onKeyDown(event);\n }\n };\n\n const input = <input {...otherProps} className={className} data-taco=\"input\" onKeyDown={handleKeyDown} ref={inputRef} />;\n\n if (hasContainer) {\n let extra: any;\n\n if (button) {\n const disabled = button.props.disabled || otherProps.disabled;\n const buttonClassName = cn(\n 'items-center flex justify-center border absolute rounded-l-none rounded-r right-0 h-full focus:rounded focus:outline-none',\n {\n [getButtonStateClasses(invalid)]: !props.disabled,\n },\n button.props.className\n );\n extra = React.cloneElement(button, {\n className: buttonClassName,\n disabled,\n });\n } else if (icon) {\n const iconClassName = cn(\n 'items-center flex justify-center absolute pointer-events-none mr-1 p-px right-0 w-5 top-1/2 -translate-y-1/2',\n {\n 'text-grey-dark': props.disabled,\n 'text-grey-darkest': !props.disabled,\n }\n );\n extra =\n typeof icon === 'string' ? (\n <Icon className={iconClassName} name={icon} />\n ) : (\n React.cloneElement(icon, { className: cn(iconClassName, icon.props.className) })\n );\n }\n\n const containerClassName = cn('bg-white inline-flex relative rounded w-full', otherProps.className);\n\n return (\n <div className={containerClassName} data-taco=\"input-container\">\n {input}\n {extra}\n </div>\n );\n }\n\n return input;\n});\n"],"names":["Input","React","props","ref","button","icon","highlighted","invalid","onKeyDown","autoFocus","otherProps","inputRef","useProxiedRef","hasContainer","className","cn","getInputClasses","current","focus","handleKeyDown","event","shiftKey","key","preventDefault","position","currentTarget","value","length","setSelectionRange","input","extra","disabled","buttonClassName","getButtonStateClasses","iconClassName","Icon","name","containerClassName"],"mappings":";;;;;;MAiBaA,KAAK,gBAAGC,UAAA,CAAiB,SAASD,KAAT,CAAeE,KAAf,EAAkCC,GAAlC;EAClC,MAAM;IAAEC,MAAF;IAAUC,IAAV;IAAgBC,WAAhB;IAA6BC,OAA7B;IAAsCC,SAAtC;IAAiDC,SAAjD;IAA4D,GAAGC;MAAeR,KAApF;EACA,MAAMS,QAAQ,GAAGC,aAAa,CAAmBT,GAAnB,CAA9B;EACA,MAAMU,YAAY,GAAGT,MAAM,IAAIC,IAA/B;EACA,MAAMS,SAAS,GAAGC,EAAE,CAChBC,eAAe,CAACd,KAAD,CADC,EAEhB,6CAFgB,EAGhB;IACI,QAAQ,CAAC,CAACW;GAJE,EAMhB,CAACA,YAAD,IAAiBH,UAAU,CAACI,SANZ,CAApB;EASAb,SAAA,CAAgB;IACZ,IAAIQ,SAAS,IAAIE,QAAQ,CAACM,OAA1B,EAAmC;MAC/BN,QAAQ,CAACM,OAAT,CAAiBC,KAAjB;;GAFR,EAIG,EAJH;;;;EASA,MAAMC,aAAa,GAAIC,KAAD;IAClB,IAAI,CAACA,KAAK,CAACC,QAAP,KAAoBD,KAAK,CAACE,GAAN,KAAc,MAAd,IAAwBF,KAAK,CAACE,GAAN,KAAc,KAA1D,CAAJ,EAAsE;MAClEF,KAAK,CAACG,cAAN;MACA,MAAMC,QAAQ,GAAGJ,KAAK,CAACE,GAAN,KAAc,KAAd,GAAsBF,KAAK,CAACK,aAAN,CAAoBC,KAApB,CAA0BC,MAAhD,GAAyD,CAA1E;MACAP,KAAK,CAACK,aAAN,CAAoBG,iBAApB,CAAsCJ,QAAtC,EAAgDA,QAAhD;;;IAGJ,IAAIhB,SAAJ,EAAe;MACXA,SAAS,CAACY,KAAD,CAAT;;GARR;;EAYA,MAAMS,KAAK,GAAG5B,aAAA,QAAA,oBAAWS;IAAYI,SAAS,EAAEA;iBAAqB;IAAQN,SAAS,EAAEW;IAAehB,GAAG,EAAEQ;IAA9F,CAAd;;EAEA,IAAIE,YAAJ,EAAkB;IACd,IAAIiB,KAAJ;;IAEA,IAAI1B,MAAJ,EAAY;MACR,MAAM2B,QAAQ,GAAG3B,MAAM,CAACF,KAAP,CAAa6B,QAAb,IAAyBrB,UAAU,CAACqB,QAArD;MACA,MAAMC,eAAe,GAAGjB,EAAE,CACtB,2HADsB,EAEtB;QACI,CAACkB,qBAAqB,CAAC1B,OAAD,CAAtB,GAAkC,CAACL,KAAK,CAAC6B;OAHvB,EAKtB3B,MAAM,CAACF,KAAP,CAAaY,SALS,CAA1B;MAOAgB,KAAK,GAAG7B,YAAA,CAAmBG,MAAnB,EAA2B;QAC/BU,SAAS,EAAEkB,eADoB;QAE/BD;OAFI,CAAR;KATJ,MAaO,IAAI1B,IAAJ,EAAU;MACb,MAAM6B,aAAa,GAAGnB,EAAE,CACpB,8GADoB,EAEpB;QACI,kBAAkBb,KAAK,CAAC6B,QAD5B;QAEI,qBAAqB,CAAC7B,KAAK,CAAC6B;OAJZ,CAAxB;MAOAD,KAAK,GACD,OAAOzB,IAAP,KAAgB,QAAhB,GACIJ,aAAA,CAACkC,IAAD;QAAMrB,SAAS,EAAEoB;QAAeE,IAAI,EAAE/B;OAAtC,CADJ,GAGIJ,YAAA,CAAmBI,IAAnB,EAAyB;QAAES,SAAS,EAAEC,EAAE,CAACmB,aAAD,EAAgB7B,IAAI,CAACH,KAAL,CAAWY,SAA3B;OAAxC,CAJR;;;IAQJ,MAAMuB,kBAAkB,GAAGtB,EAAE,CAAC,8CAAD,EAAiDL,UAAU,CAACI,SAA5D,CAA7B;IAEA,OACIb,aAAA,MAAA;MAAKa,SAAS,EAAEuB;mBAA8B;KAA9C,EACKR,KADL,EAEKC,KAFL,CADJ;;;EAQJ,OAAOD,KAAP;AACH,CA/EoB;;;;"}
@@ -1,6 +1,6 @@
1
1
  import cn from 'classnames';
2
2
 
3
- var getInputClasses = function getInputClasses(props) {
3
+ const getInputClasses = props => {
4
4
  return cn('peer bg-white text-black text-sm border font-normal not-italic no-underline rounded inline-flex leading-6 px-2 relative w-full text-ellipsis flex items-center', {
5
5
  'cursor-not-allowed text-black bg-grey': props.readOnly,
6
6
  'border-grey text-opacity-25 cursor-not-allowed': props.disabled,
@@ -10,7 +10,7 @@ var getInputClasses = function getInputClasses(props) {
10
10
  'border-red hover:shadow-[0_0_0.15rem_theme(colors.red.DEFAULT)] focus:border-red-light focus:yt-focus-red active:border-red-dark': props.invalid
11
11
  });
12
12
  };
13
- var getButtonStateClasses = function getButtonStateClasses(invalid) {
13
+ const getButtonStateClasses = invalid => {
14
14
  if (invalid) {
15
15
  return '!border-red focus:!border-red-light focus:yt-focus-red peer-focus:!border-red-light peer-focus:peer-active:!border-red-dark';
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sources":["../../../../src/components/Input/util.ts"],"sourcesContent":["import cn from 'classnames';\n\nexport const getInputClasses = props => {\n return cn(\n 'peer bg-white text-black text-sm border font-normal not-italic no-underline rounded inline-flex leading-6 px-2 relative w-full text-ellipsis flex items-center',\n {\n 'cursor-not-allowed text-black bg-grey': props.readOnly,\n 'border-grey text-opacity-25 cursor-not-allowed': props.disabled,\n 'bg-[rgba(255,255,0,0.075)]': props.highlighted && props.disabled,\n 'bg-[rgba(255,255,0,0.2)]': props.highlighted && !props.disabled,\n 'border-grey-dark hover:shadow-[0_0_0.1rem_theme(colors.grey.darker)] focus:border-blue-light focus:yt-focus active:border-blue-dark':\n !props.invalid,\n 'border-red hover:shadow-[0_0_0.15rem_theme(colors.red.DEFAULT)] focus:border-red-light focus:yt-focus-red active:border-red-dark':\n props.invalid,\n }\n );\n};\n\nexport const getButtonStateClasses = (invalid: boolean | undefined): string => {\n if (invalid) {\n return '!border-red focus:!border-red-light focus:yt-focus-red peer-focus:!border-red-light peer-focus:peer-active:!border-red-dark';\n }\n\n return '!border-grey-dark focus:!border-blue-light peer-focus:!border-blue-light peer-focus:peer-active:!border-blue-dark';\n};\n"],"names":["getInputClasses","props","cn","readOnly","disabled","highlighted","invalid","getButtonStateClasses"],"mappings":";;IAEaA,eAAe,GAAG,SAAlBA,eAAkB,CAAAC,KAAK;EAChC,OAAOC,EAAE,CACL,gKADK,EAEL;IACI,yCAAyCD,KAAK,CAACE,QADnD;IAEI,kDAAkDF,KAAK,CAACG,QAF5D;IAGI,8BAA8BH,KAAK,CAACI,WAAN,IAAqBJ,KAAK,CAACG,QAH7D;IAII,4BAA4BH,KAAK,CAACI,WAAN,IAAqB,CAACJ,KAAK,CAACG,QAJ5D;IAKI,uIACI,CAACH,KAAK,CAACK,OANf;IAOI,oIACIL,KAAK,CAACK;GAVT,CAAT;AAaH;IAEYC,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACD,OAAD;EACjC,IAAIA,OAAJ,EAAa;IACT,OAAO,6HAAP;;;EAGJ,OAAO,mHAAP;AACH;;;;"}
1
+ {"version":3,"file":"util.js","sources":["../../../../src/components/Input/util.ts"],"sourcesContent":["import cn from 'classnames';\n\nexport const getInputClasses = props => {\n return cn(\n 'peer bg-white text-black text-sm border font-normal not-italic no-underline rounded inline-flex leading-6 px-2 relative w-full text-ellipsis flex items-center',\n {\n 'cursor-not-allowed text-black bg-grey': props.readOnly,\n 'border-grey text-opacity-25 cursor-not-allowed': props.disabled,\n 'bg-[rgba(255,255,0,0.075)]': props.highlighted && props.disabled,\n 'bg-[rgba(255,255,0,0.2)]': props.highlighted && !props.disabled,\n 'border-grey-dark hover:shadow-[0_0_0.1rem_theme(colors.grey.darker)] focus:border-blue-light focus:yt-focus active:border-blue-dark':\n !props.invalid,\n 'border-red hover:shadow-[0_0_0.15rem_theme(colors.red.DEFAULT)] focus:border-red-light focus:yt-focus-red active:border-red-dark':\n props.invalid,\n }\n );\n};\n\nexport const getButtonStateClasses = (invalid: boolean | undefined): string => {\n if (invalid) {\n return '!border-red focus:!border-red-light focus:yt-focus-red peer-focus:!border-red-light peer-focus:peer-active:!border-red-dark';\n }\n\n return '!border-grey-dark focus:!border-blue-light peer-focus:!border-blue-light peer-focus:peer-active:!border-blue-dark';\n};\n"],"names":["getInputClasses","props","cn","readOnly","disabled","highlighted","invalid","getButtonStateClasses"],"mappings":";;MAEaA,eAAe,GAAGC,KAAK;EAChC,OAAOC,EAAE,CACL,gKADK,EAEL;IACI,yCAAyCD,KAAK,CAACE,QADnD;IAEI,kDAAkDF,KAAK,CAACG,QAF5D;IAGI,8BAA8BH,KAAK,CAACI,WAAN,IAAqBJ,KAAK,CAACG,QAH7D;IAII,4BAA4BH,KAAK,CAACI,WAAN,IAAqB,CAACJ,KAAK,CAACG,QAJ5D;IAKI,uIACI,CAACH,KAAK,CAACK,OANf;IAOI,oIACIL,KAAK,CAACK;GAVT,CAAT;AAaH;MAEYC,qBAAqB,GAAID,OAAD;EACjC,IAAIA,OAAJ,EAAa;IACT,OAAO,6HAAP;;;EAGJ,OAAO,mHAAP;AACH;;;;"}
@@ -1,53 +1,52 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { forwardRef, createElement } from 'react';
3
2
  import cn from 'classnames';
4
3
  import { ScrollableList } from './ScrollableList.js';
5
4
  import { useListbox } from './useListbox.js';
6
5
  import { useMultiListbox } from './useMultiListbox.js';
7
6
 
8
- var _excluded = ["className"],
9
- _excluded2 = ["className"];
10
- var Listbox = /*#__PURE__*/forwardRef(function Listbox(props, ref) {
11
- var externalClassName = props.className,
12
- otherProps = _objectWithoutPropertiesLoose(props, _excluded);
13
-
14
- var _useListbox = useListbox(otherProps, ref),
15
- list = _useListbox.list,
16
- input = _useListbox.input;
17
-
18
- var className = cn('bg-white inline-flex relative w-full', externalClassName);
7
+ const Listbox = /*#__PURE__*/forwardRef(function Listbox(props, ref) {
8
+ const {
9
+ className: externalClassName,
10
+ ...otherProps
11
+ } = props;
12
+ const {
13
+ list,
14
+ input
15
+ } = useListbox(otherProps, ref);
16
+ const className = cn('bg-white inline-flex relative w-full', externalClassName);
19
17
  return createElement("span", {
20
18
  "data-taco": "listbox",
21
19
  className: className
22
20
  }, createElement(ScrollableList, Object.assign({}, list, {
23
- style: _extends({}, list.style, {
21
+ style: { ...list.style,
24
22
  maxHeight: 'calc(12rem + 2px)'
25
23
  /* (6 * option height) + listbox border */
26
24
 
27
- })
25
+ }
28
26
  })), createElement("input", Object.assign({}, input, {
29
27
  className: "hidden",
30
28
  type: "text"
31
29
  })));
32
30
  });
33
- var MultiListbox = /*#__PURE__*/forwardRef(function Listbox(props, ref) {
34
- var externalClassName = props.className,
35
- otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
36
-
37
- var _useMultiListbox = useMultiListbox(otherProps, ref),
38
- list = _useMultiListbox.list,
39
- input = _useMultiListbox.input;
40
-
41
- var className = cn('bg-white inline-flex relative w-full', externalClassName);
31
+ const MultiListbox = /*#__PURE__*/forwardRef(function Listbox(props, ref) {
32
+ const {
33
+ className: externalClassName,
34
+ ...otherProps
35
+ } = props;
36
+ const {
37
+ list,
38
+ input
39
+ } = useMultiListbox(otherProps, ref);
40
+ const className = cn('bg-white inline-flex relative w-full', externalClassName);
42
41
  return createElement("span", {
43
42
  "data-taco": "listbox",
44
43
  className: className
45
44
  }, createElement(ScrollableList, Object.assign({}, list, {
46
- style: _extends({}, list.style, {
45
+ style: { ...list.style,
47
46
  maxHeight: 'calc(12rem + 2px + 2px)'
48
47
  /* (6 * option height) + listbox border + ALL_OPTIONS bottom border */
49
48
 
50
- })
49
+ }
51
50
  })), createElement("input", Object.assign({}, input, {
52
51
  className: "hidden",
53
52
  type: "text"
@@ -1 +1 @@
1
- {"version":3,"file":"Listbox.js","sources":["../../../../src/components/Listbox/Listbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { useListbox } from './useListbox';\nimport { useMultiListbox } from './useMultiListbox';\nimport { ScrollableList, ScrollableListItemValue, ScrollableListItem } from './ScrollableList';\n\nexport type ListboxItem = ScrollableListItem;\nexport type ListboxValue = ScrollableListItemValue;\n\nexport type ListboxTexts = {\n /**\n * Text displayed in the listbox if no data provided.\n * To read more about how to provide the text, see [Provider](component:provider) component\n */\n empty: string;\n /**\n * Text displayed in the listbox to indicate the data is loading.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading: string;\n /**\n * The first option displayed in a multiselect listbox that selects all available options.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n allOption: string;\n};\n\nexport type ListboxProps = Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onFocus'> &\n Omit<React.InputHTMLAttributes<HTMLElement>, 'defaultValue' | 'onChange' | 'value'> & {\n /** Data indicating the options in listbox */\n data?: ListboxItem[];\n /**\n * Initial value of the listbox.\n * This is used when listbox is mounted, if no value is provided.\n * *Note* that listbox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ListboxValue;\n /** Set what value should have an empty option in listbox */\n emptyValue?: ListboxValue;\n /** Draws attention to the listbox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading?: boolean;\n /**\n * Value of the listbox representing the selected item.\n * It needs to be an existing value from the provided data\n */\n value?: ListboxValue;\n };\n\nexport const Listbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useListbox(otherProps, ref);\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\n\n return (\n <span data-taco=\"listbox\" className={className}>\n <ScrollableList\n {...list}\n style={{ ...list.style, maxHeight: 'calc(12rem + 2px)' /* (6 * option height) + listbox border */ }}\n />\n <input {...input} className=\"hidden\" type=\"text\" />\n </span>\n );\n});\n\nexport const MultiListbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useMultiListbox(otherProps, ref);\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\n\n return (\n <span data-taco=\"listbox\" className={className}>\n <ScrollableList\n {...list}\n style={{\n ...list.style,\n maxHeight: 'calc(12rem + 2px + 2px)' /* (6 * option height) + listbox border + ALL_OPTIONS bottom border */,\n }}\n />\n <input {...input} className=\"hidden\" type=\"text\" />\n </span>\n );\n});\n"],"names":["Listbox","React","props","ref","externalClassName","className","otherProps","useListbox","list","input","cn","ScrollableList","style","maxHeight","type","MultiListbox","useMultiListbox"],"mappings":";;;;;;;;;IAuDaA,OAAO,gBAAGC,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;EACpC,IAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;MAAyCC,UAAzC,iCAAwDJ,KAAxD;;EACA,kBAAwBK,UAAU,CAACD,UAAD,EAAaH,GAAb,CAAlC;MAAQK,IAAR,eAAQA,IAAR;MAAcC,KAAd,eAAcA,KAAd;;EACA,IAAMJ,SAAS,GAAGK,EAAE,CAAC,sCAAD,EAAyCN,iBAAzC,CAApB;EAEA,OACIH,aAAA,OAAA;iBAAgB;IAAUI,SAAS,EAAEA;GAArC,EACIJ,aAAA,CAACU,cAAD,oBACQH;IACJI,KAAK,eAAOJ,IAAI,CAACI,KAAZ;MAAmBC,SAAS,EAAE;;;;IAFvC,CADJ,EAKIZ,aAAA,QAAA,oBAAWQ;IAAOJ,SAAS,EAAC;IAASS,IAAI,EAAC;IAA1C,CALJ,CADJ;AASH,CAdsB;IAgBVC,YAAY,gBAAGd,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;EACzC,IAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;MAAyCC,UAAzC,iCAAwDJ,KAAxD;;EACA,uBAAwBc,eAAe,CAACV,UAAD,EAAaH,GAAb,CAAvC;MAAQK,IAAR,oBAAQA,IAAR;MAAcC,KAAd,oBAAcA,KAAd;;EACA,IAAMJ,SAAS,GAAGK,EAAE,CAAC,sCAAD,EAAyCN,iBAAzC,CAApB;EAEA,OACIH,aAAA,OAAA;iBAAgB;IAAUI,SAAS,EAAEA;GAArC,EACIJ,aAAA,CAACU,cAAD,oBACQH;IACJI,KAAK,eACEJ,IAAI,CAACI,KADP;MAEDC,SAAS,EAAE;;;;IAJnB,CADJ,EAQIZ,aAAA,QAAA,oBAAWQ;IAAOJ,SAAS,EAAC;IAASS,IAAI,EAAC;IAA1C,CARJ,CADJ;AAYH,CAjB2B;;;;"}
1
+ {"version":3,"file":"Listbox.js","sources":["../../../../src/components/Listbox/Listbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { useListbox } from './useListbox';\nimport { useMultiListbox } from './useMultiListbox';\nimport { ScrollableList, ScrollableListItemValue, ScrollableListItem } from './ScrollableList';\n\nexport type ListboxItem = ScrollableListItem;\nexport type ListboxValue = ScrollableListItemValue;\n\nexport type ListboxTexts = {\n /**\n * Text displayed in the listbox if no data provided.\n * To read more about how to provide the text, see [Provider](component:provider) component\n */\n empty: string;\n /**\n * Text displayed in the listbox to indicate the data is loading.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading: string;\n /**\n * The first option displayed in a multiselect listbox that selects all available options.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n allOption: string;\n};\n\nexport type ListboxProps = Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onFocus'> &\n Omit<React.InputHTMLAttributes<HTMLElement>, 'defaultValue' | 'onChange' | 'value'> & {\n /** Data indicating the options in listbox */\n data?: ListboxItem[];\n /**\n * Initial value of the listbox.\n * This is used when listbox is mounted, if no value is provided.\n * *Note* that listbox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ListboxValue;\n /** Set what value should have an empty option in listbox */\n emptyValue?: ListboxValue;\n /** Draws attention to the listbox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading?: boolean;\n /**\n * Value of the listbox representing the selected item.\n * It needs to be an existing value from the provided data\n */\n value?: ListboxValue;\n };\n\nexport const Listbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useListbox(otherProps, ref);\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\n\n return (\n <span data-taco=\"listbox\" className={className}>\n <ScrollableList\n {...list}\n style={{ ...list.style, maxHeight: 'calc(12rem + 2px)' /* (6 * option height) + listbox border */ }}\n />\n <input {...input} className=\"hidden\" type=\"text\" />\n </span>\n );\n});\n\nexport const MultiListbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useMultiListbox(otherProps, ref);\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\n\n return (\n <span data-taco=\"listbox\" className={className}>\n <ScrollableList\n {...list}\n style={{\n ...list.style,\n maxHeight: 'calc(12rem + 2px + 2px)' /* (6 * option height) + listbox border + ALL_OPTIONS bottom border */,\n }}\n />\n <input {...input} className=\"hidden\" type=\"text\" />\n </span>\n );\n});\n"],"names":["Listbox","React","props","ref","className","externalClassName","otherProps","list","input","useListbox","cn","ScrollableList","style","maxHeight","type","MultiListbox","useMultiListbox"],"mappings":";;;;;;MAuDaA,OAAO,gBAAGC,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;EACpC,MAAM;IAAEC,SAAS,EAAEC,iBAAb;IAAgC,GAAGC;MAAeJ,KAAxD;EACA,MAAM;IAAEK,IAAF;IAAQC;MAAUC,UAAU,CAACH,UAAD,EAAaH,GAAb,CAAlC;EACA,MAAMC,SAAS,GAAGM,EAAE,CAAC,sCAAD,EAAyCL,iBAAzC,CAApB;EAEA,OACIJ,aAAA,OAAA;iBAAgB;IAAUG,SAAS,EAAEA;GAArC,EACIH,aAAA,CAACU,cAAD,oBACQJ;IACJK,KAAK,EAAE,EAAE,GAAGL,IAAI,CAACK,KAAV;MAAiBC,SAAS,EAAE;;;;IAFvC,CADJ,EAKIZ,aAAA,QAAA,oBAAWO;IAAOJ,SAAS,EAAC;IAASU,IAAI,EAAC;IAA1C,CALJ,CADJ;AASH,CAdsB;MAgBVC,YAAY,gBAAGd,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;EACzC,MAAM;IAAEC,SAAS,EAAEC,iBAAb;IAAgC,GAAGC;MAAeJ,KAAxD;EACA,MAAM;IAAEK,IAAF;IAAQC;MAAUQ,eAAe,CAACV,UAAD,EAAaH,GAAb,CAAvC;EACA,MAAMC,SAAS,GAAGM,EAAE,CAAC,sCAAD,EAAyCL,iBAAzC,CAApB;EAEA,OACIJ,aAAA,OAAA;iBAAgB;IAAUG,SAAS,EAAEA;GAArC,EACIH,aAAA,CAACU,cAAD,oBACQJ;IACJK,KAAK,EAAE,EACH,GAAGL,IAAI,CAACK,KADL;MAEHC,SAAS,EAAE;;;;IAJnB,CADJ,EAQIZ,aAAA,QAAA,oBAAWO;IAAOJ,SAAS,EAAC;IAASU,IAAI,EAAC;IAA1C,CARJ,CADJ;AAYH,CAjB2B;;;;"}
@@ -1,4 +1,3 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { forwardRef, useMemo, createRef, useEffect, createElement } from 'react';
3
2
  import cn from 'classnames';
4
3
  import { Spinner } from '../Spinner/Spinner.js';
@@ -6,17 +5,13 @@ import { useLocalization } from '../Provider/Provider.js';
6
5
  import { Checkbox } from '../Checkbox/Checkbox.js';
7
6
  import { useProxiedRef } from '../../utils/hooks/useProxiedRef.js';
8
7
  import { getInputClasses } from '../Input/util.js';
9
- import { getNextIndexFromKeycode } from '../../utils/hooks/useListKeyboardNavigation.js';
8
+ import { getNextIndexFromKey } from '../../utils/hooks/useListKeyboardNavigation.js';
10
9
  import { useListScrollTo } from '../../utils/hooks/useListScrollTo.js';
11
10
 
12
- var _excluded = ["data", "disabled", "highlighted", "id", "invalid", "loading", "onChange", "onClick", "onFocus", "onKeyDown", "readOnly", "scrollOnFocus", "value", "multiselect", "selectedIndexes", "allOptionsSelected"],
13
- _excluded2 = ["children", "icon"];
14
- var getId = function getId(id, value) {
15
- return id + "_" + value;
16
- };
11
+ const getId = (id, value) => `${id}_${value}`;
17
12
 
18
- var getNextEnabledItem = function getNextEnabledItem(event, data, index) {
19
- var nextIndex = getNextIndexFromKeycode(event.keyCode, data.length, index);
13
+ const getNextEnabledItem = (event, data, index) => {
14
+ const nextIndex = getNextIndexFromKey(event.key, data.length, index);
20
15
 
21
16
  if (nextIndex) {
22
17
  if (nextIndex === index) {
@@ -29,40 +24,35 @@ var getNextEnabledItem = function getNextEnabledItem(event, data, index) {
29
24
  return nextIndex;
30
25
  };
31
26
 
32
- var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref) {
33
- var data = props.data,
34
- disabled = props.disabled,
35
- id = props.id,
36
- loading = props.loading,
37
- setCurrentIndex = props.onChange,
38
- onClick = props.onClick,
39
- onFocus = props.onFocus,
40
- onKeyDown = props.onKeyDown,
41
- readOnly = props.readOnly,
42
- _props$scrollOnFocus = props.scrollOnFocus,
43
- scrollOnFocus = _props$scrollOnFocus === void 0 ? false : _props$scrollOnFocus,
44
- currentIndex = props.value,
45
- multiselect = props.multiselect,
46
- _props$selectedIndexe = props.selectedIndexes,
47
- selectedIndexes = _props$selectedIndexe === void 0 ? [] : _props$selectedIndexe,
48
- _props$allOptionsSele = props.allOptionsSelected,
49
- allOptionsSelected = _props$allOptionsSele === void 0 ? false : _props$allOptionsSele,
50
- otherProps = _objectWithoutPropertiesLoose(props, _excluded);
51
-
52
- var listRef = useProxiedRef(ref);
53
- var itemRefs = useMemo(function () {
54
- return data.map(function () {
55
- return createRef();
56
- });
57
- }, [data]);
58
-
59
- var _useLocalization = useLocalization(),
60
- texts = _useLocalization.texts;
61
-
62
- var _useListScrollTo = useListScrollTo(listRef, itemRefs),
63
- scrollTo = _useListScrollTo.scrollTo;
64
-
65
- useEffect(function () {
27
+ const ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref) {
28
+ const {
29
+ data,
30
+ disabled,
31
+ highlighted,
32
+ id,
33
+ invalid: _,
34
+ loading,
35
+ onChange: setCurrentIndex,
36
+ onClick,
37
+ onFocus,
38
+ onKeyDown,
39
+ readOnly,
40
+ scrollOnFocus = false,
41
+ value: currentIndex,
42
+ multiselect,
43
+ selectedIndexes = [],
44
+ allOptionsSelected = false,
45
+ ...otherProps
46
+ } = props;
47
+ const listRef = useProxiedRef(ref);
48
+ const itemRefs = useMemo(() => data.map(() => createRef()), [data]);
49
+ const {
50
+ texts
51
+ } = useLocalization();
52
+ const {
53
+ scrollTo
54
+ } = useListScrollTo(listRef, itemRefs);
55
+ useEffect(() => {
66
56
  var _itemRefs$currentInde;
67
57
 
68
58
  if (currentIndex && (_itemRefs$currentInde = itemRefs[currentIndex]) !== null && _itemRefs$currentInde !== void 0 && _itemRefs$currentInde.current) {
@@ -73,12 +63,12 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
73
63
  });
74
64
  }
75
65
  }, []);
76
- useEffect(function () {
66
+ useEffect(() => {
77
67
  scrollTo(currentIndex);
78
68
  }, [currentIndex]);
79
69
 
80
- var handleKeyDown = function handleKeyDown(event) {
81
- var nextIndex = getNextEnabledItem(event, data, currentIndex);
70
+ const handleKeyDown = event => {
71
+ const nextIndex = getNextEnabledItem(event, data, currentIndex);
82
72
 
83
73
  if (nextIndex !== undefined && nextIndex !== currentIndex) {
84
74
  event.preventDefault();
@@ -88,23 +78,21 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
88
78
 
89
79
  if (onKeyDown) {
90
80
  event.persist();
91
- var index = nextIndex !== undefined ? nextIndex : currentIndex;
81
+ const index = nextIndex !== undefined ? nextIndex : currentIndex;
92
82
  onKeyDown(event, index);
93
83
  }
94
84
  };
95
85
 
96
- var handleClick = function handleClick(index) {
97
- return function (event) {
98
- setCurrentIndex(index);
86
+ const handleClick = index => event => {
87
+ setCurrentIndex(index);
99
88
 
100
- if (onClick) {
101
- event.persist();
102
- onClick(event, index);
103
- }
104
- };
89
+ if (onClick) {
90
+ event.persist();
91
+ onClick(event, index);
92
+ }
105
93
  };
106
94
 
107
- var handleFocus = function handleFocus(event) {
95
+ const handleFocus = event => {
108
96
  if (scrollOnFocus) {
109
97
  scrollTo(currentIndex);
110
98
  }
@@ -115,36 +103,33 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
115
103
  }
116
104
  };
117
105
 
118
- var getOptionCheckedState = function getOptionCheckedState(optionValue, index) {
106
+ const getOptionCheckedState = (optionValue, index) => {
119
107
  if (optionValue === '#ALL-OPTIONS#') {
120
108
  return allOptionsSelected;
121
109
  } else if (!optionValue || !selectedIndexes) {
122
110
  return false;
123
111
  } else {
124
- return selectedIndexes.findIndex(function (i) {
125
- return i === index;
126
- }) !== -1;
112
+ return selectedIndexes.findIndex(i => i === index) !== -1;
127
113
  }
128
114
  };
129
115
 
130
- var list = _extends({}, otherProps, {
116
+ const list = { ...otherProps,
131
117
  className: cn('inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto', getInputClasses(props), {
132
118
  'yt-list--multiselect': multiselect,
133
119
  'pointer-events-none': disabled,
134
120
  'cursor-not-allowed': disabled || readOnly
135
121
  }, otherProps.className),
136
- disabled: disabled,
137
- id: id,
122
+ disabled,
123
+ id,
138
124
  onFocus: !disabled && !readOnly ? handleFocus : undefined,
139
125
  onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,
140
- readOnly: readOnly,
126
+ readOnly,
141
127
  ref: listRef,
142
128
  role: 'listbox',
143
129
  tabIndex: otherProps.tabIndex || 0
144
- });
145
-
146
- var options = data.map(function (option, index) {
147
- var depth = option.path ? option.path.split('.').length - 1 : 0;
130
+ };
131
+ const options = data.map((option, index) => {
132
+ const depth = option.path ? option.path.split('.').length - 1 : 0;
148
133
  return {
149
134
  'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,
150
135
  'data-focused': currentIndex === index,
@@ -160,7 +145,7 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
160
145
  ref: itemRefs[index],
161
146
  role: 'option',
162
147
  style: depth > 0 ? {
163
- paddingLeft: depth + 1 + "rem"
148
+ paddingLeft: `${depth + 1}rem`
164
149
  } : undefined
165
150
  };
166
151
  });
@@ -170,21 +155,17 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
170
155
  className: "yt-list__empty"
171
156
  }, createElement("span", null, createElement(Spinner, {
172
157
  delay: 0
173
- })), createElement("span", null, texts.listbox.loading)) : options.length ? options.map(function (_ref) {
174
- var children = _ref.children,
175
- icon = _ref.icon,
176
- optionProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
177
-
178
- return createElement("li", Object.assign({}, optionProps), icon, createElement("span", {
179
- className: "flex-grow truncate text-left"
180
- }, children), multiselect && createElement(Checkbox, {
181
- checked: optionProps['aria-selected'],
182
- onChange: function onChange() {
183
- return null;
184
- },
185
- className: "pointer-events-none ml-2 self-center p-px"
186
- }));
187
- }) : createElement("li", {
158
+ })), createElement("span", null, texts.listbox.loading)) : options.length ? options.map(({
159
+ children,
160
+ icon,
161
+ ...optionProps
162
+ }) => createElement("li", Object.assign({}, optionProps), icon, createElement("span", {
163
+ className: "flex-grow truncate text-left"
164
+ }, children), multiselect && createElement(Checkbox, {
165
+ checked: optionProps['aria-selected'],
166
+ onChange: () => null,
167
+ className: "pointer-events-none ml-2 self-center p-px"
168
+ }))) : createElement("li", {
188
169
  className: "yt-list__empty"
189
170
  }, createElement("span", null, texts.listbox.empty)));
190
171
  });