@economic/taco 1.1.13-alpha.0 → 1.3.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 (224) hide show
  1. package/dist/components/Group/Group.d.ts +11 -1
  2. package/dist/components/Icon/components/ChevronLeftSolid.d.ts +3 -0
  3. package/dist/components/Icon/components/ChevronRightSolid.d.ts +3 -0
  4. package/dist/components/Icon/components/index.d.ts +1 -1
  5. package/dist/components/Input/Input.d.ts +1 -1
  6. package/dist/components/Menu/Menu.d.ts +2 -2
  7. package/dist/components/Menu/components/Item.d.ts +1 -1
  8. package/dist/components/Menu/components/Link.d.ts +1 -1
  9. package/dist/components/Toast/Toast.d.ts +2 -2
  10. package/dist/components/Toast/Toaster.d.ts +2 -2
  11. package/dist/esm/components/Accordion/Accordion.js +31 -34
  12. package/dist/esm/components/Accordion/Accordion.js.map +1 -1
  13. package/dist/esm/components/Backdrop/Backdrop.js +2 -2
  14. package/dist/esm/components/Backdrop/Backdrop.js.map +1 -1
  15. package/dist/esm/components/Badge/Badge.js +14 -14
  16. package/dist/esm/components/Badge/Badge.js.map +1 -1
  17. package/dist/esm/components/Banner/Banner.js +7 -5
  18. package/dist/esm/components/Banner/Banner.js.map +1 -1
  19. package/dist/esm/components/Banner/util.js +1 -1
  20. package/dist/esm/components/Banner/util.js.map +1 -1
  21. package/dist/esm/components/Button/Button.js +12 -13
  22. package/dist/esm/components/Button/Button.js.map +1 -1
  23. package/dist/esm/components/Button/util.js +18 -23
  24. package/dist/esm/components/Button/util.js.map +1 -1
  25. package/dist/esm/components/Calendar/Calendar.js +56 -71
  26. package/dist/esm/components/Calendar/Calendar.js.map +1 -1
  27. package/dist/esm/components/Card/Card.js +13 -12
  28. package/dist/esm/components/Card/Card.js.map +1 -1
  29. package/dist/esm/components/Checkbox/Checkbox.js +15 -18
  30. package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
  31. package/dist/esm/components/Combobox/Combobox.js +23 -25
  32. package/dist/esm/components/Combobox/Combobox.js.map +1 -1
  33. package/dist/esm/components/Combobox/useCombobox.js +78 -99
  34. package/dist/esm/components/Combobox/useCombobox.js.map +1 -1
  35. package/dist/esm/components/Datepicker/Datepicker.js +48 -52
  36. package/dist/esm/components/Datepicker/Datepicker.js.map +1 -1
  37. package/dist/esm/components/Datepicker/useDatepicker.js +27 -34
  38. package/dist/esm/components/Datepicker/useDatepicker.js.map +1 -1
  39. package/dist/esm/components/Dialog/Context.js +4 -4
  40. package/dist/esm/components/Dialog/Context.js.map +1 -1
  41. package/dist/esm/components/Dialog/Dialog.js +39 -58
  42. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  43. package/dist/esm/components/Dialog/components/Content.js +39 -44
  44. package/dist/esm/components/Dialog/components/Content.js.map +1 -1
  45. package/dist/esm/components/Dialog/components/Drawer.js +3 -3
  46. package/dist/esm/components/Dialog/components/Drawer.js.map +1 -1
  47. package/dist/esm/components/Dialog/components/Extra.js +2 -2
  48. package/dist/esm/components/Dialog/components/Extra.js.map +1 -1
  49. package/dist/esm/components/Dialog/components/Trigger.js +2 -2
  50. package/dist/esm/components/Dialog/components/Trigger.js.map +1 -1
  51. package/dist/esm/components/Field/Field.js +10 -12
  52. package/dist/esm/components/Field/Field.js.map +1 -1
  53. package/dist/esm/components/Form/Form.js +6 -8
  54. package/dist/esm/components/Form/Form.js.map +1 -1
  55. package/dist/esm/components/Group/Group.js +9 -8
  56. package/dist/esm/components/Group/Group.js.map +1 -1
  57. package/dist/esm/components/Hanger/Hanger.js +27 -35
  58. package/dist/esm/components/Hanger/Hanger.js.map +1 -1
  59. package/dist/esm/components/HoverCard/HoverCard.js +8 -9
  60. package/dist/esm/components/HoverCard/HoverCard.js.map +1 -1
  61. package/dist/esm/components/Icon/Icon.js +7 -8
  62. package/dist/esm/components/Icon/Icon.js.map +1 -1
  63. package/dist/esm/components/Icon/components/ChevronLeftSolid.js +20 -0
  64. package/dist/esm/components/Icon/components/ChevronLeftSolid.js.map +1 -0
  65. package/dist/esm/components/Icon/components/ChevronRightSolid.js +20 -0
  66. package/dist/esm/components/Icon/components/ChevronRightSolid.js.map +1 -0
  67. package/dist/esm/components/Icon/components/index.js +8 -4
  68. package/dist/esm/components/Icon/components/index.js.map +1 -1
  69. package/dist/esm/components/IconButton/IconButton.js +9 -11
  70. package/dist/esm/components/IconButton/IconButton.js.map +1 -1
  71. package/dist/esm/components/Input/Input.js +25 -25
  72. package/dist/esm/components/Input/Input.js.map +1 -1
  73. package/dist/esm/components/Input/util.js +2 -2
  74. package/dist/esm/components/Input/util.js.map +1 -1
  75. package/dist/esm/components/Listbox/Listbox.js +24 -25
  76. package/dist/esm/components/Listbox/Listbox.js.map +1 -1
  77. package/dist/esm/components/Listbox/ScrollableList.js +65 -84
  78. package/dist/esm/components/Listbox/ScrollableList.js.map +1 -1
  79. package/dist/esm/components/Listbox/useListbox.js +53 -61
  80. package/dist/esm/components/Listbox/useListbox.js.map +1 -1
  81. package/dist/esm/components/Listbox/useMultiListbox.js +69 -96
  82. package/dist/esm/components/Listbox/useMultiListbox.js.map +1 -1
  83. package/dist/esm/components/Listbox/useTypeahead.js +10 -9
  84. package/dist/esm/components/Listbox/useTypeahead.js.map +1 -1
  85. package/dist/esm/components/Listbox/util.js +48 -85
  86. package/dist/esm/components/Listbox/util.js.map +1 -1
  87. package/dist/esm/components/Menu/Context.js +2 -2
  88. package/dist/esm/components/Menu/Context.js.map +1 -1
  89. package/dist/esm/components/Menu/Menu.js +16 -34
  90. package/dist/esm/components/Menu/Menu.js.map +1 -1
  91. package/dist/esm/components/Menu/components/Checkbox.js +9 -10
  92. package/dist/esm/components/Menu/components/Checkbox.js.map +1 -1
  93. package/dist/esm/components/Menu/components/Content.js +9 -11
  94. package/dist/esm/components/Menu/components/Content.js.map +1 -1
  95. package/dist/esm/components/Menu/components/Header.js +3 -3
  96. package/dist/esm/components/Menu/components/Header.js.map +1 -1
  97. package/dist/esm/components/Menu/components/Item.js +30 -31
  98. package/dist/esm/components/Menu/components/Item.js.map +1 -1
  99. package/dist/esm/components/Menu/components/Link.js +10 -11
  100. package/dist/esm/components/Menu/components/Link.js.map +1 -1
  101. package/dist/esm/components/Menu/components/RadioGroup.js +17 -19
  102. package/dist/esm/components/Menu/components/RadioGroup.js.map +1 -1
  103. package/dist/esm/components/Menu/components/Separator.js +1 -1
  104. package/dist/esm/components/Menu/components/Separator.js.map +1 -1
  105. package/dist/esm/components/Menu/components/Trigger.js +4 -4
  106. package/dist/esm/components/Menu/components/Trigger.js.map +1 -1
  107. package/dist/esm/components/Navigation/Navigation.js +35 -44
  108. package/dist/esm/components/Navigation/Navigation.js.map +1 -1
  109. package/dist/esm/components/Pagination/PageNumbers.js +23 -28
  110. package/dist/esm/components/Pagination/PageNumbers.js.map +1 -1
  111. package/dist/esm/components/Pagination/Pagination.js +39 -56
  112. package/dist/esm/components/Pagination/Pagination.js.map +1 -1
  113. package/dist/esm/components/Pagination/usePagination.js +7 -21
  114. package/dist/esm/components/Pagination/usePagination.js.map +1 -1
  115. package/dist/esm/components/Pagination/usePaginationShortcuts.js +13 -14
  116. package/dist/esm/components/Pagination/usePaginationShortcuts.js.map +1 -1
  117. package/dist/esm/components/Popover/Popover.js +29 -34
  118. package/dist/esm/components/Popover/Popover.js.map +1 -1
  119. package/dist/esm/components/Popover/Primitives.js +7 -8
  120. package/dist/esm/components/Popover/Primitives.js.map +1 -1
  121. package/dist/esm/components/Progress/Progress.js +11 -15
  122. package/dist/esm/components/Progress/Progress.js.map +1 -1
  123. package/dist/esm/components/Provider/Provider.js +13 -18
  124. package/dist/esm/components/Provider/Provider.js.map +1 -1
  125. package/dist/esm/components/RadioGroup/RadioGroup.js +45 -57
  126. package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -1
  127. package/dist/esm/components/SearchInput/SearchInput.js +10 -12
  128. package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
  129. package/dist/esm/components/Select/Select.js +30 -31
  130. package/dist/esm/components/Select/Select.js.map +1 -1
  131. package/dist/esm/components/Select/useSelect.js +69 -88
  132. package/dist/esm/components/Select/useSelect.js.map +1 -1
  133. package/dist/esm/components/Spinner/Spinner.js +12 -19
  134. package/dist/esm/components/Spinner/Spinner.js.map +1 -1
  135. package/dist/esm/components/Switch/Switch.js +9 -10
  136. package/dist/esm/components/Switch/Switch.js.map +1 -1
  137. package/dist/esm/components/Table/components/BaseTable.js +23 -30
  138. package/dist/esm/components/Table/components/BaseTable.js.map +1 -1
  139. package/dist/esm/components/Table/components/PaginatedTable.js +3 -7
  140. package/dist/esm/components/Table/components/PaginatedTable.js.map +1 -1
  141. package/dist/esm/components/Table/components/Table.js +18 -25
  142. package/dist/esm/components/Table/components/Table.js.map +1 -1
  143. package/dist/esm/components/Table/components/WindowedTable.js +89 -109
  144. package/dist/esm/components/Table/components/WindowedTable.js.map +1 -1
  145. package/dist/esm/components/Table/hooks/plugins/useRowActions.js +123 -148
  146. package/dist/esm/components/Table/hooks/plugins/useRowActions.js.map +1 -1
  147. package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js +57 -61
  148. package/dist/esm/components/Table/hooks/plugins/useRowDraggable.js.map +1 -1
  149. package/dist/esm/components/Table/hooks/plugins/useRowEditing.js +39 -36
  150. package/dist/esm/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
  151. package/dist/esm/components/Table/hooks/plugins/useRowSelect.js +79 -89
  152. package/dist/esm/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
  153. package/dist/esm/components/Table/hooks/useRowCreation.js +29 -64
  154. package/dist/esm/components/Table/hooks/useRowCreation.js.map +1 -1
  155. package/dist/esm/components/Table/hooks/useTable.js +123 -141
  156. package/dist/esm/components/Table/hooks/useTable.js.map +1 -1
  157. package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js +23 -27
  158. package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js.map +1 -1
  159. package/dist/esm/components/Table/util/renderColumn.js +10 -10
  160. package/dist/esm/components/Table/util/renderColumn.js.map +1 -1
  161. package/dist/esm/components/Table/util/renderRow.js +37 -46
  162. package/dist/esm/components/Table/util/renderRow.js.map +1 -1
  163. package/dist/esm/components/Table/util/rowIndexPath.js +14 -16
  164. package/dist/esm/components/Table/util/rowIndexPath.js.map +1 -1
  165. package/dist/esm/components/Table/util/sortTypes.js +23 -31
  166. package/dist/esm/components/Table/util/sortTypes.js.map +1 -1
  167. package/dist/esm/components/Table/util.js +29 -41
  168. package/dist/esm/components/Table/util.js.map +1 -1
  169. package/dist/esm/components/Tabs/Tabs.js +25 -27
  170. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  171. package/dist/esm/components/Textarea/Textarea.js +11 -9
  172. package/dist/esm/components/Textarea/Textarea.js.map +1 -1
  173. package/dist/esm/components/Toast/Toast.js +27 -23
  174. package/dist/esm/components/Toast/Toast.js.map +1 -1
  175. package/dist/esm/components/Toast/Toaster.js +88 -118
  176. package/dist/esm/components/Toast/Toaster.js.map +1 -1
  177. package/dist/esm/components/Toast/util.js +2 -2
  178. package/dist/esm/components/Toast/util.js.map +1 -1
  179. package/dist/esm/components/Tooltip/Tooltip.js +7 -8
  180. package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
  181. package/dist/esm/components/Tour/Tour.js +46 -53
  182. package/dist/esm/components/Tour/Tour.js.map +1 -1
  183. package/dist/esm/components/Treeview/Treeview.js +26 -36
  184. package/dist/esm/components/Treeview/Treeview.js.map +1 -1
  185. package/dist/esm/components/VisuallyHidden/VisuallyHidden.js +1 -1
  186. package/dist/esm/components/VisuallyHidden/VisuallyHidden.js.map +1 -1
  187. package/dist/esm/index.css +1 -9
  188. package/dist/esm/index.js +1 -1
  189. package/dist/esm/primitives/Button.js +9 -13
  190. package/dist/esm/primitives/Button.js.map +1 -1
  191. package/dist/esm/utils/date.js +20 -40
  192. package/dist/esm/utils/date.js.map +1 -1
  193. package/dist/esm/utils/hooks/useBoundingClientRectListener.js +12 -20
  194. package/dist/esm/utils/hooks/useBoundingClientRectListener.js.map +1 -1
  195. package/dist/esm/utils/hooks/useDraggable.js +16 -17
  196. package/dist/esm/utils/hooks/useDraggable.js.map +1 -1
  197. package/dist/esm/utils/hooks/useDropTarget.js +7 -10
  198. package/dist/esm/utils/hooks/useDropTarget.js.map +1 -1
  199. package/dist/esm/utils/hooks/useListKeyboardNavigation.js +15 -30
  200. package/dist/esm/utils/hooks/useListKeyboardNavigation.js.map +1 -1
  201. package/dist/esm/utils/hooks/useListScrollTo.js +9 -9
  202. package/dist/esm/utils/hooks/useListScrollTo.js.map +1 -1
  203. package/dist/esm/utils/hooks/useOnClickOutside.js +6 -8
  204. package/dist/esm/utils/hooks/useOnClickOutside.js.map +1 -1
  205. package/dist/esm/utils/hooks/useProxiedRef.js +3 -3
  206. package/dist/esm/utils/hooks/useProxiedRef.js.map +1 -1
  207. package/dist/esm/utils/hooks/useTimer.js +9 -17
  208. package/dist/esm/utils/hooks/useTimer.js.map +1 -1
  209. package/dist/esm/utils/input.js +8 -12
  210. package/dist/esm/utils/input.js.map +1 -1
  211. package/dist/esm/utils/mergeRefs.js +2 -2
  212. package/dist/esm/utils/mergeRefs.js.map +1 -1
  213. package/dist/esm/utils/taillwind.js +2 -2
  214. package/dist/esm/utils/taillwind.js.map +1 -1
  215. package/dist/index.css +1 -9
  216. package/dist/taco.cjs.development.js +2368 -2883
  217. package/dist/taco.cjs.development.js.map +1 -1
  218. package/dist/taco.cjs.production.min.js +1 -1
  219. package/dist/taco.cjs.production.min.js.map +1 -1
  220. package/dist/utils/hooks/useListKeyboardNavigation.d.ts +1 -1
  221. package/package.json +4 -5
  222. package/types.json +13 -4
  223. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +0 -34
  224. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
@@ -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,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;EACvC,IAAmBC,iBAAnB,GAA+GF,KAA/G,CAAQG,SAAR;MAA+CC,WAA/C,GAA+GJ,KAA/G,CAAsCK,OAAtC;MAA4DC,KAA5D,GAA+GN,KAA/G,CAA4DM,KAA5D;MAAmEC,SAAnE,GAA+GP,KAA/G,CAAmEO,SAAnE;MAA8EC,aAA9E,GAA+GR,KAA/G,CAA8EQ,aAA9E;MAAgGC,UAAhG,iCAA+GT,KAA/G;;EACA,qBAA4BU,aAAa,CAACD,UAAD,EAAaR,GAAb,CAAzC;MAAQU,QAAR,kBAAQA,QAAR;MAAkBC,KAAlB,kBA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,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;EACv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AAc,CAACC,QAAD,EAAWC,CAAX,KACXpC,aAAA,KAAA;MAAIqC,GAAG,EAAED;KAAT,EACIpC,aAAA,SAAA;MACIG,SAAS,EAAC;MACVmC,OAAO,EAAEN,KAAK;QACVA,KAAK,CAACO,OAAN;QACAJ,QAAQ,CAACG,OAAT,CAAiBN,KAAjB;QACAJ,KAAK;;KALb,EAQKO,QAAQ,CAACK,IARd,CADJ,CADH,CADL,CAJJ,EAoBKlC,WAAW,IACRN,aAAA,SAAA;MACIG,SAAS,EAAC;MACVmC,OAAO,EAAEN,KAAK;QACVA,KAAK,CAACO,OAAN;QACAjC,WAAW,CAAC0B,KAAD,CAAX;QACAJ,KAAK;;KALb,EAQKd,KAAK,CAACQ,UAAN,CAAiBmB,KARtB,CArBR,CAVR,CAFR,CARJ;IAHR,CADJ,CADJ;AAmEH,CAzEyB;;;;"}
@@ -1,31 +1,26 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { useState, useEffect } from 'react';
3
2
  import { useLocalization } from '../Provider/Provider.js';
4
3
  import { useProxiedRef } from '../../utils/hooks/useProxiedRef.js';
5
4
  import { setInputValueByRef } from '../../utils/input.js';
6
5
  import { format, parseFromCustomString } from '../../utils/date.js';
7
6
 
8
- var _excluded = ["defaultValue", "calendar", "onBlur", "onChange", "value"];
9
- var useDatepicker = function useDatepicker(_ref, ref) {
10
- var calendar = _ref.calendar,
11
- onBlur = _ref.onBlur,
12
- onChange = _ref.onChange,
13
- value = _ref.value,
14
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
15
-
16
- var inputRef = useProxiedRef(ref);
17
-
18
- var _useLocalization = useLocalization(),
19
- formatting = _useLocalization.formatting;
20
-
21
- var _React$useState = useState(value ? format(value, formatting.date) : ''),
22
- internalValue = _React$useState[0],
23
- setInternalValue = _React$useState[1]; // update internal value if it changed 'externally'
24
-
25
-
26
- useEffect(function () {
7
+ const useDatepicker = ({
8
+ defaultValue: _,
9
+ calendar,
10
+ onBlur,
11
+ onChange,
12
+ value,
13
+ ...props
14
+ }, ref) => {
15
+ const inputRef = useProxiedRef(ref);
16
+ const {
17
+ formatting
18
+ } = useLocalization();
19
+ const [internalValue, setInternalValue] = useState(value ? format(value, formatting.date) : ''); // update internal value if it changed 'externally'
20
+
21
+ useEffect(() => {
27
22
  if (value) {
28
- var formattedValue = format(value, formatting.date);
23
+ const formattedValue = format(value, formatting.date);
29
24
 
30
25
  if (formattedValue !== internalValue) {
31
26
  setInternalValue(formattedValue);
@@ -35,10 +30,10 @@ var useDatepicker = function useDatepicker(_ref, ref) {
35
30
  }
36
31
  }, [value]); // event handlers
37
32
 
38
- var handleInputBlur = function handleInputBlur(event) {
33
+ const handleInputBlur = event => {
39
34
  event.persist();
40
- var valueAsDate = parseFromCustomString(event.target.value);
41
- var formattedValue = valueAsDate ? format(valueAsDate) || '' : '';
35
+ const valueAsDate = parseFromCustomString(event.target.value);
36
+ const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';
42
37
  event.target.value = formattedValue;
43
38
 
44
39
  if (onChange) {
@@ -54,15 +49,15 @@ var useDatepicker = function useDatepicker(_ref, ref) {
54
49
  }
55
50
  };
56
51
 
57
- var handleInputChange = function handleInputChange(event) {
52
+ const handleInputChange = event => {
58
53
  setInternalValue(event.target.value);
59
54
  };
60
55
 
61
- var handleChange = function handleChange(date) {
56
+ const handleChange = date => {
62
57
  setInputValueByRef(inputRef.current, format(date, formatting.date), 'focusout');
63
58
  };
64
59
 
65
- var handleKeyDown = function handleKeyDown(event) {
60
+ const handleKeyDown = event => {
66
61
  if (event.key === 'Enter') {
67
62
  event.target.dispatchEvent(new Event('focusout', {
68
63
  bubbles: true
@@ -70,7 +65,7 @@ var useDatepicker = function useDatepicker(_ref, ref) {
70
65
  }
71
66
  };
72
67
 
73
- var inputProps = _extends({}, props, {
68
+ const inputProps = { ...props,
74
69
  autoComplete: 'off',
75
70
  onBlur: handleInputBlur,
76
71
  onChange: handleInputChange,
@@ -78,13 +73,11 @@ var useDatepicker = function useDatepicker(_ref, ref) {
78
73
  ref: inputRef,
79
74
  type: 'text',
80
75
  value: internalValue
81
- });
82
-
83
- var calendarProps = _extends({}, calendar, {
76
+ };
77
+ const calendarProps = { ...calendar,
84
78
  onChange: handleChange,
85
- value: value
86
- });
87
-
79
+ value
80
+ };
88
81
  return {
89
82
  input: inputProps,
90
83
  calendar: calendarProps
@@ -1 +1 @@
1
- {"version":3,"file":"useDatepicker.js","sources":["../../../../src/components/Datepicker/useDatepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { parseFromCustomString, format } from '../../utils/date';\nimport { useLocalization } from '../Provider/Provider';\nimport { setInputValueByRef } from '../../utils/input';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { DatepickerProps } from './Datepicker';\nimport { CalendarProps } from '../Calendar/Calendar';\n\ntype InputProps = React.InputHTMLAttributes<HTMLInputElement> & { ref: React.RefObject<HTMLInputElement> };\n\ntype useDatepicker = React.HTMLAttributes<HTMLDivElement> & {\n calendar: CalendarProps;\n input: InputProps;\n};\n\nexport const useDatepicker = (\n { defaultValue: _, calendar, onBlur, onChange, value, ...props }: DatepickerProps,\n ref: React.Ref<HTMLInputElement>\n): useDatepicker => {\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const { formatting } = useLocalization();\n const [internalValue, setInternalValue] = React.useState(value ? format(value, formatting.date) : '');\n\n // update internal value if it changed 'externally'\n React.useEffect(() => {\n if (value) {\n const formattedValue = format(value, formatting.date);\n\n if (formattedValue !== internalValue) {\n setInternalValue(formattedValue);\n }\n } else {\n setInternalValue('');\n }\n }, [value]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n const valueAsDate = parseFromCustomString(event.target.value);\n const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';\n\n event.target.value = formattedValue;\n\n if (onChange) {\n (event as any).detail = valueAsDate;\n onChange(event);\n } else {\n // update the internal value to use the formatted date\n setInternalValue(formattedValue);\n }\n\n if (onBlur) {\n onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInternalValue(event.target.value);\n };\n\n const handleChange = date => {\n setInputValueByRef(inputRef.current, format(date, formatting.date), 'focusout');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.target.dispatchEvent(new Event('focusout', { bubbles: true }));\n }\n };\n\n const inputProps: InputProps = {\n ...props,\n autoComplete: 'off',\n onBlur: handleInputBlur,\n onChange: handleInputChange,\n onKeyDown: handleKeyDown,\n ref: inputRef,\n type: 'text',\n value: internalValue,\n };\n\n const calendarProps: CalendarProps = {\n ...calendar,\n onChange: handleChange,\n value,\n };\n\n return {\n input: inputProps,\n calendar: calendarProps,\n };\n};\n"],"names":["useDatepicker","ref","calendar","onBlur","onChange","value","props","inputRef","useProxiedRef","useLocalization","formatting","React","format","date","internalValue","setInternalValue","formattedValue","handleInputBlur","event","persist","valueAsDate","parseFromCustomString","target","detail","handleInputChange","handleChange","setInputValueByRef","current","handleKeyDown","key","dispatchEvent","Event","bubbles","inputProps","autoComplete","onKeyDown","type","calendarProps","input"],"mappings":";;;;;;;;IAeaA,aAAa,GAAG,SAAhBA,aAAgB,OAEzBC,GAFyB;MACNC,gBAAAA;MAAUC,cAAAA;MAAQC,gBAAAA;MAAUC,aAAAA;MAAUC;;EAGzD,IAAMC,QAAQ,GAAGC,aAAa,CAAmBP,GAAnB,CAA9B;;EACA,uBAAuBQ,eAAe,EAAtC;MAAQC,UAAR,oBAAQA,UAAR;;EACA,sBAA0CC,QAAA,CAAeN,KAAK,GAAGO,MAAM,CAACP,KAAD,EAAQK,UAAU,CAACG,IAAnB,CAAT,GAAoC,EAAxD,CAA1C;MAAOC,aAAP;MAAsBC,gBAAtB;;;EAGAJ,SAAA,CAAgB;IACZ,IAAIN,KAAJ,EAAW;MACP,IAAMW,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,EAAsB;QAAEC,OAAO,EAAE;OAAjC,CAA3B;;GAFR;;EAMA,IAAMC,UAAU,gBACT3B,KADS;IAEZ4B,YAAY,EAAE,KAFF;IAGZ/B,MAAM,EAAEc,eAHI;IAIZb,QAAQ,EAAEoB,iBAJE;IAKZW,SAAS,EAAEP,aALC;IAMZ3B,GAAG,EAAEM,QANO;IAOZ6B,IAAI,EAAE,MAPM;IAQZ/B,KAAK,EAAES;IARX;;EAWA,IAAMuB,aAAa,gBACZnC,QADY;IAEfE,QAAQ,EAAEqB,YAFK;IAGfpB,KAAK,EAALA;IAHJ;;EAMA,OAAO;IACHiC,KAAK,EAAEL,UADJ;IAEH/B,QAAQ,EAAEmC;GAFd;AAIH;;;;"}
1
+ {"version":3,"file":"useDatepicker.js","sources":["../../../../src/components/Datepicker/useDatepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { parseFromCustomString, format } from '../../utils/date';\nimport { useLocalization } from '../Provider/Provider';\nimport { setInputValueByRef } from '../../utils/input';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { DatepickerProps } from './Datepicker';\nimport { CalendarProps } from '../Calendar/Calendar';\n\ntype InputProps = React.InputHTMLAttributes<HTMLInputElement> & { ref: React.RefObject<HTMLInputElement> };\n\ntype useDatepicker = React.HTMLAttributes<HTMLDivElement> & {\n calendar: CalendarProps;\n input: InputProps;\n};\n\nexport const useDatepicker = (\n { defaultValue: _, calendar, onBlur, onChange, value, ...props }: DatepickerProps,\n ref: React.Ref<HTMLInputElement>\n): useDatepicker => {\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const { formatting } = useLocalization();\n const [internalValue, setInternalValue] = React.useState(value ? format(value, formatting.date) : '');\n\n // update internal value if it changed 'externally'\n React.useEffect(() => {\n if (value) {\n const formattedValue = format(value, formatting.date);\n\n if (formattedValue !== internalValue) {\n setInternalValue(formattedValue);\n }\n } else {\n setInternalValue('');\n }\n }, [value]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n const valueAsDate = parseFromCustomString(event.target.value);\n const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';\n\n event.target.value = formattedValue;\n\n if (onChange) {\n (event as any).detail = valueAsDate;\n onChange(event);\n } else {\n // update the internal value to use the formatted date\n setInternalValue(formattedValue);\n }\n\n if (onBlur) {\n onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInternalValue(event.target.value);\n };\n\n const handleChange = date => {\n setInputValueByRef(inputRef.current, format(date, formatting.date), 'focusout');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.target.dispatchEvent(new Event('focusout', { bubbles: true }));\n }\n };\n\n const inputProps: InputProps = {\n ...props,\n autoComplete: 'off',\n onBlur: handleInputBlur,\n onChange: handleInputChange,\n onKeyDown: handleKeyDown,\n ref: inputRef,\n type: 'text',\n value: internalValue,\n };\n\n const calendarProps: CalendarProps = {\n ...calendar,\n onChange: handleChange,\n value,\n };\n\n return {\n input: inputProps,\n calendar: calendarProps,\n };\n};\n"],"names":["useDatepicker","defaultValue","_","calendar","onBlur","onChange","value","props","ref","inputRef","useProxiedRef","formatting","useLocalization","internalValue","setInternalValue","React","format","date","formattedValue","handleInputBlur","event","persist","valueAsDate","parseFromCustomString","target","detail","handleInputChange","handleChange","setInputValueByRef","current","handleKeyDown","key","dispatchEvent","Event","bubbles","inputProps","autoComplete","onKeyDown","type","calendarProps","input"],"mappings":";;;;;;MAeaA,aAAa,GAAG,CACzB;EAAEC,YAAY,EAAEC,CAAhB;EAAmBC,QAAnB;EAA6BC,MAA7B;EAAqCC,QAArC;EAA+CC,KAA/C;EAAsD,GAAGC;AAAzD,CADyB,EAEzBC,GAFyB;EAIzB,MAAMC,QAAQ,GAAGC,aAAa,CAAmBF,GAAnB,CAA9B;EACA,MAAM;IAAEG;MAAeC,eAAe,EAAtC;EACA,MAAM,CAACC,aAA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W,GAAN,KAAc,OAAlB,EAA2B;MACvBX,KAAK,CAACI,MAAN,CAAaQ,aAAb,CAA2B,IAAIC,KAAJ,CAAU,UAAV,EAAsB;QAAEC,OAAO,EAAE;OAAjC,CAA3B;;GAFR;;EAMA,MAAMC,UAAU,GAAe,EAC3B,GAAG5B,KADwB;IAE3B6B,YAAY,EAAE,KAFa;IAG3BhC,MAAM,EAAEe,eAHmB;IAI3Bd,QAAQ,EAAEqB,iBAJiB;IAK3BW,SAAS,EAAEP,aALgB;IAM3BtB,GAAG,EAAEC,QANsB;IAO3B6B,IAAI,EAAE,MAPqB;IAQ3BhC,KAAK,EAAEO;GARX;EAWA,MAAM0B,aAAa,GAAkB,EACjC,GAAGpC,QAD8B;IAEjCE,QAAQ,EAAEsB,YAFuB;IAGjCrB;GAHJ;EAMA,OAAO;IACHkC,KAAK,EAAEL,UADJ;IAEHhC,QAAQ,EAAEoC;GAFd;AAIH;;;;"}
@@ -1,24 +1,24 @@
1
1
  import { createContext, useContext } from 'react';
2
2
 
3
3
  /* eslint-disable @typescript-eslint/no-empty-function */
4
- var DialogContext = /*#__PURE__*/createContext({
4
+ const DialogContext = /*#__PURE__*/createContext({
5
5
  closeOnEscape: true,
6
6
  draggable: false,
7
7
  drawer: {
8
8
  open: false,
9
- toggle: function toggle() {}
9
+ toggle: () => {}
10
10
  },
11
11
  elements: {
12
12
  drawer: undefined,
13
13
  extra: undefined
14
14
  },
15
- onClose: function onClose() {},
15
+ onClose: () => {},
16
16
  props: {},
17
17
  ref: null,
18
18
  showCloseButton: true,
19
19
  size: 'sm'
20
20
  });
21
- var useCurrentDialog = function useCurrentDialog() {
21
+ const useCurrentDialog = () => {
22
22
  return useContext(DialogContext);
23
23
  };
24
24
 
@@ -1 +1 @@
1
- {"version":3,"file":"Context.js","sources":["../../../../src/components/Dialog/Context.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\nimport * as React from 'react';\nimport { DialogSize } from './types';\n\nexport type DialogContext = {\n closeOnEscape: boolean;\n draggable: boolean;\n drawer: {\n open: boolean;\n toggle: () => void;\n };\n elements: {\n drawer?: React.ReactNode;\n extra?: React.ReactNode;\n };\n onClose?: () => void;\n props: {};\n ref: React.Ref<HTMLElement>;\n showCloseButton: boolean;\n size: DialogSize;\n};\n\nexport const DialogContext = React.createContext<DialogContext>({\n closeOnEscape: true,\n draggable: false,\n drawer: {\n open: false,\n toggle: () => {},\n },\n elements: {\n drawer: undefined,\n extra: undefined,\n },\n onClose: () => {},\n props: {},\n ref: null,\n showCloseButton: true,\n size: 'sm',\n});\n\nexport const useCurrentDialog = () => {\n return React.useContext(DialogContext);\n};\n"],"names":["DialogContext","React","closeOnEscape","draggable","drawer","open","toggle","elements","undefined","extra","onClose","props","ref","showCloseButton","size","useCurrentDialog"],"mappings":";;AAAA;IAsBaA,aAAa,gBAAGC,aAAA,CAAmC;EAC5DC,aAAa,EAAE,IAD6C;EAE5DC,SAAS,EAAE,KAFiD;EAG5DC,MAAM,EAAE;IACJC,IAAI,EAAE,KADF;IAEJC,MAAM,EAAE;GALgD;EAO5DC,QAAQ,EAAE;IACNH,MAAM,EAAEI,SADF;IAENC,KAAK,EAAED;GATiD;EAW5DE,OAAO,EAAE,qBAXmD;EAY5DC,KAAK,EAAE,EAZqD;EAa5DC,GAAG,EAAE,IAbuD;EAc5DC,eAAe,EAAE,IAd2C;EAe5DC,IAAI,EAAE;AAfsD,CAAnC;IAkBhBC,gBAAgB,GAAG,SAAnBA,gBAAmB;EAC5B,OAAOd,UAAA,CAAiBD,aAAjB,CAAP;AACH;;;;"}
1
+ {"version":3,"file":"Context.js","sources":["../../../../src/components/Dialog/Context.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\nimport * as React from 'react';\nimport { DialogSize } from './types';\n\nexport type DialogContext = {\n closeOnEscape: boolean;\n draggable: boolean;\n drawer: {\n open: boolean;\n toggle: () => void;\n };\n elements: {\n drawer?: React.ReactNode;\n extra?: React.ReactNode;\n };\n onClose?: () => void;\n props: {};\n ref: React.Ref<HTMLElement>;\n showCloseButton: boolean;\n size: DialogSize;\n};\n\nexport const DialogContext = React.createContext<DialogContext>({\n closeOnEscape: true,\n draggable: false,\n drawer: {\n open: false,\n toggle: () => {},\n },\n elements: {\n drawer: undefined,\n extra: undefined,\n },\n onClose: () => {},\n props: {},\n ref: null,\n showCloseButton: true,\n size: 'sm',\n});\n\nexport const useCurrentDialog = () => {\n return React.useContext(DialogContext);\n};\n"],"names":["DialogContext","React","closeOnEscape","draggable","drawer","open","toggle","elements","undefined","extra","onClose","props","ref","showCloseButton","size","useCurrentDialog"],"mappings":";;AAAA;MAsBaA,aAAa,gBAAGC,aAAA,CAAmC;EAC5DC,aAAa,EAAE,IAD6C;EAE5DC,SAAS,EAAE,KAFiD;EAG5DC,MAAM,EAAE;IACJC,IAAI,EAAE,KADF;IAEJC,MAAM,EAAE;GALgD;EAO5DC,QAAQ,EAAE;IACNH,MAAM,EAAEI,SADF;IAENC,KAAK,EAAED;GATiD;EAW5DE,OAAO,EAAE,QAXmD;EAY5DC,KAAK,EAAE,EAZqD;EAa5DC,GAAG,EAAE,IAbuD;EAc5DC,eAAe,EAAE,IAd2C;EAe5DC,IAAI,EAAE;AAfsD,CAAnC;MAkBhBC,gBAAgB,GAAG;EAC5B,OAAOd,UAAA,CAAiBD,aAAjB,CAAP;AACH;;;;"}
@@ -1,4 +1,3 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import { forwardRef, useMemo, Children, useState, createElement } from 'react';
3
2
  import { Root } from '@radix-ui/react-dialog';
4
3
  import { DialogContext } from './Context.js';
@@ -7,14 +6,12 @@ import { Content, Title, Footer, Close } from './components/Content.js';
7
6
  import { Drawer } from './components/Drawer.js';
8
7
  import { Extra } from './components/Extra.js';
9
8
 
10
- var _excluded = ["children", "closeOnEscape", "defaultOpen", "draggable", "onChange", "onClose", "open", "showCloseButton", "size", "trigger"];
11
-
12
- var useSeparatedChildren = function useSeparatedChildren(initialChildren) {
13
- return useMemo(function () {
14
- var children = [];
15
- var drawer;
16
- var extra;
17
- Children.toArray(initialChildren).forEach(function (child) {
9
+ const useSeparatedChildren = initialChildren => {
10
+ return useMemo(() => {
11
+ const children = [];
12
+ let drawer;
13
+ let extra;
14
+ Children.toArray(initialChildren).forEach(child => {
18
15
  var _child$type, _child$type2;
19
16
 
20
17
  if (((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) === Drawer.displayName) {
@@ -29,55 +26,39 @@ var useSeparatedChildren = function useSeparatedChildren(initialChildren) {
29
26
  }, [initialChildren]);
30
27
  };
31
28
 
32
- var Dialog = /*#__PURE__*/forwardRef(function Dialog(props, ref) {
33
- var initialChildren = props.children,
34
- _props$closeOnEscape = props.closeOnEscape,
35
- closeOnEscape = _props$closeOnEscape === void 0 ? true : _props$closeOnEscape,
36
- defaultOpen = props.defaultOpen,
37
- _props$draggable = props.draggable,
38
- draggable = _props$draggable === void 0 ? false : _props$draggable,
39
- onChange = props.onChange,
40
- onClose = props.onClose,
41
- open = props.open,
42
- _props$showCloseButto = props.showCloseButton,
43
- showCloseButton = _props$showCloseButto === void 0 ? true : _props$showCloseButto,
44
- _props$size = props.size,
45
- size = _props$size === void 0 ? 'sm' : _props$size,
46
- trigger = props.trigger,
47
- otherProps = _objectWithoutPropertiesLoose(props, _excluded);
48
-
49
- var _useSeparatedChildren = useSeparatedChildren(initialChildren),
50
- children = _useSeparatedChildren[0],
51
- drawer = _useSeparatedChildren[1],
52
- extra = _useSeparatedChildren[2];
53
-
54
- var _React$useState = useState(false),
55
- drawerOpen = _React$useState[0],
56
- setDrawerOpen = _React$useState[1];
57
-
58
- var context = useMemo(function () {
59
- return {
60
- closeOnEscape: closeOnEscape,
61
- draggable: draggable,
62
- drawer: {
63
- open: drawerOpen,
64
- toggle: function toggle() {
65
- return setDrawerOpen(function (isDrawerOpen) {
66
- return !isDrawerOpen;
67
- });
68
- }
69
- },
70
- elements: {
71
- drawer: drawer,
72
- extra: extra
73
- },
74
- onClose: onClose,
75
- props: otherProps,
76
- showCloseButton: showCloseButton,
77
- size: size,
78
- ref: ref
79
- };
80
- }, [closeOnEscape, drawerOpen, draggable, drawer, extra, open, otherProps, showCloseButton]);
29
+ const Dialog = /*#__PURE__*/forwardRef(function Dialog(props, ref) {
30
+ const {
31
+ children: initialChildren,
32
+ closeOnEscape = true,
33
+ defaultOpen,
34
+ draggable = false,
35
+ onChange,
36
+ onClose,
37
+ open,
38
+ showCloseButton = true,
39
+ size = 'sm',
40
+ trigger,
41
+ ...otherProps
42
+ } = props;
43
+ const [children, drawer, extra] = useSeparatedChildren(initialChildren);
44
+ const [drawerOpen, setDrawerOpen] = useState(false);
45
+ const context = useMemo(() => ({
46
+ closeOnEscape,
47
+ draggable,
48
+ drawer: {
49
+ open: drawerOpen,
50
+ toggle: () => setDrawerOpen(isDrawerOpen => !isDrawerOpen)
51
+ },
52
+ elements: {
53
+ drawer,
54
+ extra
55
+ },
56
+ onClose,
57
+ props: otherProps,
58
+ showCloseButton,
59
+ size,
60
+ ref
61
+ }), [closeOnEscape, drawerOpen, draggable, drawer, extra, open, otherProps, showCloseButton]);
81
62
  return createElement(DialogContext.Provider, {
82
63
  value: context
83
64
  }, createElement(Root, {
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport './Dialog.css';\nimport { DialogTriggerProps, Trigger } from './components/Trigger';\nimport {\n Content,\n Title,\n Footer,\n Close,\n DialogContentProps,\n DialogContentRenderProps,\n DialogContentDrawerRenderProps,\n DialogTitleProps,\n DialogFooterProps,\n DialogCloseProps,\n} from './components/Content';\nimport { DialogDrawerProps, DialogDrawerRenderProps, Drawer } from './components/Drawer';\nimport { DialogExtraProps, Extra } from './components/Extra';\nimport { DialogContext } from './Context';\nimport { DialogSize } from './types';\n\nexport {\n DialogCloseProps,\n DialogContentDrawerRenderProps,\n DialogContentProps,\n DialogContentRenderProps,\n DialogDrawerProps,\n DialogDrawerRenderProps,\n DialogFooterProps,\n DialogSize,\n DialogTitleProps,\n};\n\nexport type DialogTexts = {\n /**\n * Aria-label for close icon button in dialog.\n * To read more about how to provide the text, see [Provider](component:provider) component\n */\n close: string;\n drag: string;\n};\n\nexport type DialogProps = {\n children: React.ReactNode | React.ReactNode[];\n /** When `true`, pressing escape will close the dialog */\n closeOnEscape?: boolean;\n /** Set whether the dialog is open by default or not, use when not providing a trigger */\n defaultOpen?: boolean;\n /** Allows dragging the dialog around the screen (window constrained) */\n draggable?: boolean;\n /** Handler called when dialog closes by user interaction */\n onClose?: () => void;\n /** Called when the dialog opens or closes, must be used in conjunction with open */\n onChange?: (open: boolean) => void;\n /** Control the open state of the dialog from outside the component */\n open?: boolean;\n /** Shows the close icon button of the dialog */\n showCloseButton?: boolean;\n /** Size of the dialog. This is the recommended way to set a size for dialog component. */\n size?: DialogSize;\n /** A trigger to be used for the dialog, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n};\n\nconst useSeparatedChildren = initialChildren => {\n return React.useMemo(() => {\n const children: any[] = [];\n let drawer;\n let extra;\n\n React.Children.toArray(initialChildren).forEach((child: any) => {\n if (child.type?.displayName === Drawer.displayName) {\n drawer = child;\n } else if (child.type?.displayName === Extra.displayName) {\n extra = child;\n } else {\n children.push(child);\n }\n });\n\n return [children, drawer, extra];\n }, [initialChildren]);\n};\n\nexport type ForwardedDialogWithStatics = React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLElement>> & {\n Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n Content: React.ForwardRefExoticComponent<DialogContentProps & React.RefAttributes<HTMLDivElement>>;\n Title: React.ForwardRefExoticComponent<DialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n Footer: React.ForwardRefExoticComponent<DialogFooterProps & React.RefAttributes<HTMLDivElement>>;\n Extra: React.ForwardRefExoticComponent<DialogExtraProps & React.RefAttributes<HTMLDivElement>>;\n Drawer: React.ForwardRefExoticComponent<DialogDrawerProps & React.RefAttributes<HTMLDivElement>>;\n Close: React.ForwardRefExoticComponent<DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;\n};\n\nexport const Dialog = React.forwardRef(function Dialog(props: DialogProps, ref: React.Ref<HTMLElement>) {\n const {\n children: initialChildren,\n closeOnEscape = true,\n defaultOpen,\n draggable = false,\n onChange,\n onClose,\n open,\n showCloseButton = true,\n size = 'sm',\n trigger,\n ...otherProps\n } = props;\n const [children, drawer, extra] = useSeparatedChildren(initialChildren);\n const [drawerOpen, setDrawerOpen] = React.useState(false);\n\n const context = React.useMemo(\n () => ({\n closeOnEscape,\n draggable,\n drawer: {\n open: drawerOpen,\n toggle: () => setDrawerOpen(isDrawerOpen => !isDrawerOpen),\n },\n elements: {\n drawer,\n extra,\n },\n onClose,\n props: otherProps,\n showCloseButton,\n size,\n ref,\n }),\n [closeOnEscape, drawerOpen, draggable, drawer, extra, open, otherProps, showCloseButton]\n );\n\n return (\n <DialogContext.Provider value={context}>\n <DialogPrimitive.Root defaultOpen={defaultOpen} open={open} onOpenChange={onChange}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {children}\n </DialogPrimitive.Root>\n </DialogContext.Provider>\n );\n}) as ForwardedDialogWithStatics;\n\nDialog.Trigger = Trigger;\nDialog.Content = Content;\nDialog.Title = Title;\nDialog.Footer = Footer;\nDialog.Extra = Extra;\nDialog.Drawer = Drawer;\nDialog.Close = Close;\n"],"names":["useSeparatedChildren","initialChildren","React","children","drawer","extra","toArray","forEach","child","type","displayName","Drawer","Extra","push","Dialog","props","ref","closeOnEscape","defaultOpen","draggable","onChange","onClose","open","showCloseButton","size","trigger","otherProps","drawerOpen","setDrawerOpen","context","toggle","isDrawerOpen","elements","DialogContext","Provider","value","DialogPrimitive","onOpenChange","Trigger","Content","Title","Footer","Close"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AhB;AACA3B,MAAM,CAACF,KAAP,GAAeA,KAAf;AACAE,MAAM,CAACH,MAAP,GAAgBA,MAAhB;AACAG,MAAM,CAAC4B,KAAP,GAAeA,KAAf;;;;"}
1
+ {"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport './Dialog.css';\nimport { DialogTriggerProps, Trigger } from './components/Trigger';\nimport {\n Content,\n Title,\n Footer,\n Close,\n DialogContentProps,\n DialogContentRenderProps,\n DialogContentDrawerRenderProps,\n DialogTitleProps,\n DialogFooterProps,\n DialogCloseProps,\n} from './components/Content';\nimport { DialogDrawerProps, DialogDrawerRenderProps, Drawer } from './components/Drawer';\nimport { DialogExtraProps, Extra } from './components/Extra';\nimport { DialogContext } from './Context';\nimport { DialogSize } from './types';\n\nexport {\n DialogCloseProps,\n DialogContentDrawerRenderProps,\n DialogContentProps,\n DialogContentRenderProps,\n DialogDrawerProps,\n DialogDrawerRenderProps,\n DialogFooterProps,\n DialogSize,\n DialogTitleProps,\n};\n\nexport type DialogTexts = {\n /**\n * Aria-label for close icon button in dialog.\n * To read more about how to provide the text, see [Provider](component:provider) component\n */\n close: string;\n drag: string;\n};\n\nexport type DialogProps = {\n children: React.ReactNode | React.ReactNode[];\n /** When `true`, pressing escape will close the dialog */\n closeOnEscape?: boolean;\n /** Set whether the dialog is open by default or not, use when not providing a trigger */\n defaultOpen?: boolean;\n /** Allows dragging the dialog around the screen (window constrained) */\n draggable?: boolean;\n /** Handler called when dialog closes by user interaction */\n onClose?: () => void;\n /** Called when the dialog opens or closes, must be used in conjunction with open */\n onChange?: (open: boolean) => void;\n /** Control the open state of the dialog from outside the component */\n open?: boolean;\n /** Shows the close icon button of the dialog */\n showCloseButton?: boolean;\n /** Size of the dialog. This is the recommended way to set a size for dialog component. */\n size?: DialogSize;\n /** A trigger to be used for the dialog, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n};\n\nconst useSeparatedChildren = initialChildren => {\n return React.useMemo(() => {\n const children: any[] = [];\n let drawer;\n let extra;\n\n React.Children.toArray(initialChildren).forEach((child: any) => {\n if (child.type?.displayName === Drawer.displayName) {\n drawer = child;\n } else if (child.type?.displayName === Extra.displayName) {\n extra = child;\n } else {\n children.push(child);\n }\n });\n\n return [children, drawer, extra];\n }, [initialChildren]);\n};\n\nexport type ForwardedDialogWithStatics = React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLElement>> & {\n Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n Content: React.ForwardRefExoticComponent<DialogContentProps & React.RefAttributes<HTMLDivElement>>;\n Title: React.ForwardRefExoticComponent<DialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n Footer: React.ForwardRefExoticComponent<DialogFooterProps & React.RefAttributes<HTMLDivElement>>;\n Extra: React.ForwardRefExoticComponent<DialogExtraProps & React.RefAttributes<HTMLDivElement>>;\n Drawer: React.ForwardRefExoticComponent<DialogDrawerProps & React.RefAttributes<HTMLDivElement>>;\n Close: React.ForwardRefExoticComponent<DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;\n};\n\nexport const Dialog = React.forwardRef(function Dialog(props: DialogProps, ref: React.Ref<HTMLElement>) {\n const {\n children: initialChildren,\n closeOnEscape = true,\n defaultOpen,\n draggable = false,\n onChange,\n onClose,\n open,\n showCloseButton = true,\n size = 'sm',\n trigger,\n ...otherProps\n } = props;\n const [children, drawer, extra] = useSeparatedChildren(initialChildren);\n const [drawerOpen, setDrawerOpen] = React.useState(false);\n\n const context = React.useMemo(\n () => ({\n closeOnEscape,\n draggable,\n drawer: {\n open: drawerOpen,\n toggle: () => setDrawerOpen(isDrawerOpen => !isDrawerOpen),\n },\n elements: {\n drawer,\n extra,\n },\n onClose,\n props: otherProps,\n showCloseButton,\n size,\n ref,\n }),\n [closeOnEscape, drawerOpen, draggable, drawer, extra, open, otherProps, showCloseButton]\n );\n\n return (\n <DialogContext.Provider value={context}>\n <DialogPrimitive.Root defaultOpen={defaultOpen} open={open} onOpenChange={onChange}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {children}\n </DialogPrimitive.Root>\n </DialogContext.Provider>\n );\n}) as ForwardedDialogWithStatics;\n\nDialog.Trigger = Trigger;\nDialog.Content = Content;\nDialog.Title = Title;\nDialog.Footer = Footer;\nDialog.Extra = Extra;\nDialog.Drawer = Drawer;\nDialog.Close = Close;\n"],"names":["useSeparatedChildren","initialChildren","React","children","drawer","extra","toArray","forEach","child","type","displayName","Drawer","Extra","push","Dialog","props","ref","closeOnEscape","defaultOpen","draggable","onChange","onClose","open","showCloseButton","size","trigger","otherProps","drawerOpen","setDrawerOpen","context","toggle","isDrawerOpen","elements","DialogContext","Provider","value","DialogPrimitive","onOpenChange","Trigger","Content","Title","Footer","Close"],"mappings":";;;;;;;;AAgEA,MAAMA,oBAAoB,GAAGC,eAAe;EACxC,OAAOC,OAAA,CAAc;IACjB,MAAMC,QAAQ,GAAU,EAAxB;IACA,IAAIC,MAAJ;IACA,IAAIC,KAAJ;IAEAH,QAAA,CAAeI,OAAf,CAAuBL,eAAvB,EAAwCM,OAAxC,CAAiDC,KAAD;;;MAC5C,IAAI,gBAAAA,KAAK,CAACC,IAAN,4DAAYC,WAAZ,MAA4BC,MAAM,CAACD,WAAvC,EAAoD;QAChDN,MAAM,GAAGI,KAAT;OADJ,MAEO,IAAI,iBAAAA,KAAK,CAACC,IAAN,8DAAYC,WAAZ,MAA4BE,KAAK,CAACF,WAAtC,EAAmD;QACtDL,KAAK,GAAGG,KAAR;OADG,MAEA;QACHL,QAAQ,CAACU,IAAT,CAAcL,KAAd;;KANR;IAUA,OAAO,CAACL,QAAD,EAAWC,MAAX,EAAmBC,KAAnB,CAAP;GAfG,EAgBJ,CAACJ,eAAD,CAhBI,CAAP;AAiBH,CAlBD;;MA8Baa,MAAM,gBAAGZ,UAAA,CAAiB,SAASY,MAAT,CAAgBC,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