@jobber/components 4.41.0 → 4.42.1-update-hov.11

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 (184) hide show
  1. package/Chip.d.ts +1 -0
  2. package/Chip.js +17 -0
  3. package/Combobox.d.ts +1 -0
  4. package/Combobox.js +17 -0
  5. package/Flex.d.ts +1 -0
  6. package/Flex.js +17 -0
  7. package/dist/Autocomplete/index.js +8 -8
  8. package/dist/Avatar/index.js +1 -1
  9. package/dist/{Avatar-1aa30ee1.js → Avatar-76a799fa.js} +1 -1
  10. package/dist/Banner/index.js +5 -5
  11. package/dist/Button/index.js +2 -2
  12. package/dist/Button-163a0641.js +57 -0
  13. package/dist/ButtonDismiss/index.js +3 -3
  14. package/dist/{ButtonDismiss-82680c7d.js → ButtonDismiss-2b98d075.js} +1 -1
  15. package/dist/Card/index.js +5 -5
  16. package/dist/{Card-cc2ffbaa.js → Card-3178033c.js} +4 -4
  17. package/dist/Checkbox/index.js +3 -3
  18. package/dist/{Checkbox-3bccf65c.js → Checkbox-ad7ec2e7.js} +2 -2
  19. package/dist/Chip/Chip.d.ts +8 -0
  20. package/dist/Chip/components/ChipDismissible/ChipDismissible.d.ts +3 -0
  21. package/dist/Chip/components/ChipPrefix/Chip.Prefix.d.ts +2 -0
  22. package/dist/Chip/components/ChipSelectable/ChipSelectable.d.ts +3 -0
  23. package/dist/Chip/components/ChipSuffix/Chip.Suffix.d.ts +6 -0
  24. package/dist/Chip/hooks/index.d.ts +1 -0
  25. package/dist/Chip/hooks/useChildComponent.d.ts +8 -0
  26. package/dist/Chip/index.d.ts +3 -0
  27. package/dist/Chip/index.js +40 -0
  28. package/dist/Chip-55e6da05.js +89 -0
  29. package/dist/Chips/index.js +505 -19
  30. package/dist/Combobox/Combobox.d.ts +11 -0
  31. package/dist/Combobox/Combobox.types.d.ts +189 -0
  32. package/dist/Combobox/ComboboxProvider.d.ts +20 -0
  33. package/dist/Combobox/components/ComboboxAction/ComboboxAction.d.ts +3 -0
  34. package/dist/Combobox/components/ComboboxAction/index.d.ts +1 -0
  35. package/dist/Combobox/components/ComboboxActivator/ComboboxActivator.d.ts +3 -0
  36. package/dist/Combobox/components/ComboboxActivator/index.d.ts +1 -0
  37. package/dist/Combobox/components/ComboboxContent/ComboboxContent.d.ts +3 -0
  38. package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/ComboboxContentHeader.d.ts +3 -0
  39. package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/index.d.ts +1 -0
  40. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/ComboboxContentList.d.ts +3 -0
  41. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.d.ts +1 -0
  42. package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/ComboboxContentSearch.d.ts +3 -0
  43. package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/index.d.ts +1 -0
  44. package/dist/Combobox/components/ComboboxContent/index.d.ts +1 -0
  45. package/dist/Combobox/components/ComboboxOption/ComboboxOption.d.ts +6 -0
  46. package/dist/Combobox/components/ComboboxOption/index.d.ts +1 -0
  47. package/dist/Combobox/components/ComboboxTrigger/ComboboxTrigger.d.ts +3 -0
  48. package/dist/Combobox/components/ComboboxTrigger/index.d.ts +1 -0
  49. package/dist/Combobox/hooks/useCombobox.d.ts +15 -0
  50. package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +13 -0
  51. package/dist/Combobox/hooks/useComboboxContent.d.ts +8 -0
  52. package/dist/Combobox/hooks/useComboboxValidation.d.ts +12 -0
  53. package/dist/Combobox/hooks/useMakeComboboxHandlers.d.ts +7 -0
  54. package/dist/Combobox/index.d.ts +3 -0
  55. package/dist/Combobox/index.js +31 -0
  56. package/dist/Combobox-0044641d.js +403 -0
  57. package/dist/ConfirmationModal/index.js +9 -9
  58. package/dist/{ConfirmationModal-6b61ebf5.js → ConfirmationModal-f7234e44.js} +2 -2
  59. package/dist/Content/Content.d.ts +1 -1
  60. package/dist/DataDump/index.js +6 -6
  61. package/dist/DataList/DataList.d.ts +10 -3
  62. package/dist/DataList/DataList.types.d.ts +80 -5
  63. package/dist/DataList/DataList.utils.d.ts +5 -4
  64. package/dist/DataList/components/DataListAction/DataListAction.d.ts +2 -3
  65. package/dist/DataList/components/DataListActions/DataListActions.d.ts +3 -0
  66. package/dist/DataList/components/DataListActions/index.d.ts +1 -0
  67. package/dist/DataList/components/DataListActionsMenu/DataListActionsMenu.d.ts +2 -2
  68. package/dist/DataList/components/DataListBulkActions/DataListBulkActions.const.d.ts +1 -0
  69. package/dist/DataList/components/DataListBulkActions/DataListBulkActions.d.ts +4 -0
  70. package/dist/DataList/components/DataListBulkActions/index.d.ts +1 -0
  71. package/dist/DataList/components/DataListHeader/DataListHeader.d.ts +2 -0
  72. package/dist/DataList/components/DataListHeader/index.d.ts +1 -0
  73. package/dist/DataList/components/DataListItem/DataListItem.d.ts +9 -0
  74. package/dist/DataList/components/{DataListLayoutInternal → DataListItem}/DataListItemInternal.d.ts +1 -1
  75. package/dist/DataList/components/DataListItem/components/DataListItemClickable/DataListItemClickable.d.ts +2 -0
  76. package/dist/DataList/components/DataListItem/components/DataListItemClickable/DataListItemClickableInternal.d.ts +3 -0
  77. package/dist/DataList/components/DataListItem/components/DataListItemClickable/index.d.ts +1 -0
  78. package/dist/DataList/components/DataListItem/index.d.ts +1 -0
  79. package/dist/DataList/components/DataListItemActions/DataListItemActions.d.ts +4 -4
  80. package/dist/DataList/components/DataListItemActionsOverflow/DataListItemActionsOverflow.d.ts +7 -0
  81. package/dist/DataList/components/DataListItemActionsOverflow/index.d.ts +1 -0
  82. package/dist/DataList/components/DataListItems/DataListItems.d.ts +7 -0
  83. package/dist/DataList/components/DataListItems/index.d.ts +1 -0
  84. package/dist/DataList/components/DataListLayout/DataListLayout.d.ts +2 -2
  85. package/dist/DataList/components/DataListLayoutActions/DataListLayoutActions.d.ts +2 -0
  86. package/dist/DataList/components/DataListLayoutActions/DataListLayoutContext/DataListLayoutContext.d.ts +4 -0
  87. package/dist/DataList/components/DataListLayoutActions/DataListLayoutContext/index.d.ts +1 -0
  88. package/dist/DataList/components/DataListLayoutActions/index.d.ts +1 -0
  89. package/dist/DataList/components/DataListLoadingState/DataListLoadingState.d.ts +2 -9
  90. package/dist/DataList/components/DataListOverflowFade/DataListOverflowFade.d.ts +6 -0
  91. package/dist/DataList/components/DataListOverflowFade/index.d.ts +2 -0
  92. package/dist/DataList/components/DataListSearch/DataListSearch.d.ts +1 -1
  93. package/dist/DataList/components/DataListStatusBar/DataListStatusBar.d.ts +10 -0
  94. package/dist/DataList/components/DataListStatusBar/index.d.ts +1 -0
  95. package/dist/DataList/context/DataListContext/DataListContext.d.ts +4 -10
  96. package/dist/DataList/context/DataListLayoutContext/DataListLayoutContext.d.ts +5 -0
  97. package/dist/DataList/context/DataListLayoutContext/index.d.ts +1 -0
  98. package/dist/DataList/hooks/useActiveLayout.d.ts +4 -0
  99. package/dist/DataList/hooks/useGetItemActions.d.ts +6 -0
  100. package/dist/DataList/index.js +626 -376
  101. package/dist/DataTable/DataTable.d.ts +10 -10
  102. package/dist/DataTable/Pagination.d.ts +6 -5
  103. package/dist/DataTable/index.js +20 -14
  104. package/dist/DatePicker/index.js +3 -3
  105. package/dist/{DatePicker-b31baae4.js → DatePicker-c18f1739.js} +3 -3
  106. package/dist/DescriptionList/index.js +2 -2
  107. package/dist/Disclosure/index.js +2 -2
  108. package/dist/Drawer/index.js +5 -5
  109. package/dist/Emphasis/index.js +2 -2
  110. package/dist/{Emphasis-76a10790.js → Emphasis-b2d1b3aa.js} +1 -1
  111. package/dist/FeatureSwitch/index.js +7 -7
  112. package/dist/Flex/Flex.d.ts +32 -0
  113. package/dist/Flex/Flex.types.d.ts +6 -0
  114. package/dist/Flex/index.d.ts +1 -0
  115. package/dist/Flex/index.js +40 -0
  116. package/dist/FormField/index.js +5 -5
  117. package/dist/{FormField-d6138b7f.js → FormField-0b529c0b.js} +4 -4
  118. package/dist/FormatFile/index.js +11 -11
  119. package/dist/{FormatFile-aa1898f9.js → FormatFile-6bc7f045.js} +6 -6
  120. package/dist/Gallery/index.js +12 -12
  121. package/dist/Heading/index.js +2 -2
  122. package/dist/{Heading-a1191b15.js → Heading-0f4ecb0c.js} +1 -1
  123. package/dist/InlineLabel/index.js +2 -2
  124. package/dist/{InlineLabel-afd5fc6f.js → InlineLabel-9a517c19.js} +2 -2
  125. package/dist/InputAvatar/index.js +5 -5
  126. package/dist/InputDate/index.js +6 -6
  127. package/dist/InputEmail/index.js +5 -5
  128. package/dist/InputFile/index.js +3 -3
  129. package/dist/{InputFile-2a06c2c0.js → InputFile-8a21a5fb.js} +3 -3
  130. package/dist/InputNumber/index.js +6 -6
  131. package/dist/{InputNumber-07b03067.js → InputNumber-6a7cefc6.js} +1 -1
  132. package/dist/InputPassword/index.js +5 -5
  133. package/dist/InputPhoneNumber/index.js +5 -5
  134. package/dist/InputText/index.js +6 -6
  135. package/dist/{InputText-d1a52550.js → InputText-dcf6c428.js} +1 -1
  136. package/dist/InputTime/index.js +5 -5
  137. package/dist/InputValidation/index.js +3 -3
  138. package/dist/{InputValidation-b5a3d92c.js → InputValidation-179f0926.js} +2 -2
  139. package/dist/LightBox/index.js +4 -4
  140. package/dist/{LightBox-437a1c8b.js → LightBox-3f4dbc33.js} +2 -2
  141. package/dist/Link/Link.d.ts +1 -2
  142. package/dist/Link/index.d.ts +1 -1
  143. package/dist/List/index.js +7 -7
  144. package/dist/Markdown/index.js +5 -5
  145. package/dist/{Markdown-f6748dcb.js → Markdown-96070121.js} +3 -3
  146. package/dist/Menu/index.js +3 -3
  147. package/dist/{Menu-51f8712f.js → Menu-d7ea093c.js} +3 -3
  148. package/dist/Modal/index.js +5 -5
  149. package/dist/{Modal-a9ab9565.js → Modal-b9d194e4.js} +4 -4
  150. package/dist/MultiSelect/index.js +5 -5
  151. package/dist/{Option-b903e7ac.js → Option-752ce1e8.js} +1 -1
  152. package/dist/Page/index.js +7 -7
  153. package/dist/Popover/index.js +50 -9
  154. package/dist/ProgressBar/index.js +1 -1
  155. package/dist/{ProgressBar-5dfc1885.js → ProgressBar-250e7b24.js} +1 -1
  156. package/dist/RadioGroup/index.js +3 -3
  157. package/dist/{RadioGroup-8e76d20b.js → RadioGroup-ebaa4f87.js} +2 -2
  158. package/dist/RecurringSelect/index.js +11 -11
  159. package/dist/Select/index.js +6 -6
  160. package/dist/StatusLabel/index.js +2 -2
  161. package/dist/Switch/index.js +2 -2
  162. package/dist/{Switch-e75145cc.js → Switch-b85272bf.js} +2 -2
  163. package/dist/Tabs/Tabs.d.ts +12 -1
  164. package/dist/Tabs/index.js +8 -4
  165. package/dist/Text/index.js +2 -2
  166. package/dist/{Text-e7ed0974.js → Text-4a2bc89f.js} +1 -1
  167. package/dist/Toast/index.js +2 -2
  168. package/dist/Tooltip/index.js +1 -3
  169. package/dist/{Tooltip-bf67fe6e.js → Tooltip-6b12f1c2.js} +6 -8
  170. package/dist/Typography/index.js +1 -1
  171. package/dist/{Typography-fd6f932a.js → Typography-973b122e.js} +3 -3
  172. package/package.json +7 -7
  173. package/rollup.config.js +3 -5
  174. package/dist/Button-fd8413b2.js +0 -57
  175. package/dist/Chip-4916a642.js +0 -514
  176. package/dist/DataList/components/DataListItemActions/DataListItemActionsOverflow.d.ts +0 -7
  177. package/dist/DataList/components/DataListLayoutInternal/DataListHeader.d.ts +0 -11
  178. package/dist/DataList/components/DataListLayoutInternal/DataListItems.d.ts +0 -10
  179. package/dist/DataList/components/DataListLayoutInternal/DataListLayoutInternal.d.ts +0 -10
  180. package/dist/DataList/components/DataListLayoutInternal/index.d.ts +0 -3
  181. package/dist/DataList/hooks/useLayoutMediaQueries.d.ts +0 -1
  182. package/dist/Popover-bbfc6aa1.js +0 -53
  183. /package/dist/DataList/components/{DataListLayoutInternal → DataListHeader}/DataListHeaderCheckbox.d.ts +0 -0
  184. /package/dist/DataList/components/{DataListFilters/DataListFilter.const.d.ts → DataListOverflowFade/DataListOverflowFade.const.d.ts} +0 -0
@@ -0,0 +1,403 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var classnames = require('classnames');
5
+ var ReactDOM = require('react-dom');
6
+ var styleInject_es = require('./style-inject.es-9d2f5f4e.js');
7
+ var Icon = require('./Icon-405a216c.js');
8
+ var Text = require('./Text-4a2bc89f.js');
9
+ var Typography = require('./Typography-973b122e.js');
10
+ var Button = require('./Button-163a0641.js');
11
+ var useRefocusOnActivator = require('@jobber/hooks/useRefocusOnActivator');
12
+ var useFocusTrap = require('@jobber/hooks/useFocusTrap');
13
+ var reactPopper = require('react-popper');
14
+ var useOnKeyDown = require('@jobber/hooks/useOnKeyDown');
15
+ var Chip = require('./Chip-55e6da05.js');
16
+ require('@jobber/design');
17
+ var useAssert = require('@jobber/hooks/useAssert');
18
+
19
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
+
21
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
+ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
23
+ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
24
+
25
+ var css_248z$6 = ".m1w5vdUZ6rQ- {\n z-index: 1002;\n z-index: var(--elevation-tooltip);\n max-width: var(--popover--width);\n min-width: calc((16px * 4) * 3.75);\n min-width: calc(calc(16px * 4) * 3.75);\n min-width: calc(var(--space-extravagant) * 3.75);\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n border: calc(16px / 16) solid rgb(217, 223, 225);\n border: var(--border-base) solid var(--color-border);\n border-radius: calc(16px / 2);\n border-radius: var(--radius-larger);\n overflow: scroll;\n overflow-y: auto;\n background: rgba(255, 255, 255, 1);\n background: var(--color-surface);\n}\n\n/* CAUTION: Tests for content visibility assume this class' presence hides the content\n* so please be careful if you change this class name, or the css rules within.\n*/\n\n.m1w5vdUZ6rQ-.Zlkv2HA096A- {\n display: none;\n visibility: hidden;\n}\n\n.YQry-Rd6zfQ- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n position: sticky;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n bottom: 0;\n width: 100%;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.TcpqL34s4lI- {\n padding-bottom: calc(16px / 2);\n padding-bottom: var(--space-small);\n}\n";
26
+ var styles$6 = {"content":"m1w5vdUZ6rQ-","hidden":"Zlkv2HA096A-","actions":"YQry-Rd6zfQ-","actionPadding":"TcpqL34s4lI-"};
27
+ styleInject_es.styleInject(css_248z$6);
28
+
29
+ var css_248z$5 = ".MIyb-oFZg9w- {\n position: relative;\n}\n\n.WZPK91I4aJs- {\n width: 100%;\n padding: calc(16px * 1);\n padding: var(--space-base);\n padding-right: calc((16px * 1.5) * 2.25);\n padding-right: calc(calc(16px * 1.5) * 2.25);\n padding-right: calc(var(--space-large) * 2.25);\n border: none;\n border-bottom: calc(16px / 16) solid rgb(217, 223, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n font-family: \"Inter\", Helvetica, Arial, sans-serif;\n font-family: var(--typography--fontFamily-normal);\n font-size: calc((16px * 1) * 0.875);\n font-size: calc(calc(16px * 1) * 0.875);\n font-size: var(--typography--fontSize-base);\n}\n\n.WZPK91I4aJs-::-webkit-search-decoration,\n.WZPK91I4aJs-::-webkit-search-cancel-button,\n.WZPK91I4aJs-::-webkit-search-results-button,\n.WZPK91I4aJs-::-webkit-search-results-decoration {\n -webkit-appearance: none;\n}\n\n.WZPK91I4aJs-:focus {\n outline: none;\n}\n\n._7loHrVUe-Rk- {\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n top: 50%;\n right: calc(16px * 1);\n right: var(--space-base);\n z-index: 1002;\n z-index: var(--elevation-tooltip);\n width: calc(16px * 1.5);\n width: var(--space-large);\n height: calc(16px * 1.5);\n height: var(--space-large);\n padding: 0;\n border: none;\n border-radius: 100%;\n border-radius: var(--radius-circle);\n background-color: rgb(238, 240, 242);\n background-color: var(--color-surface--background);\n cursor: pointer;\n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: center;\n align-items: center;\n}\n\n._7loHrVUe-Rk-:focus {\n box-shadow: 0px 0px 0px calc(16px / 8) rgba(255, 255, 255, 1),\n 0px 0px 0px calc(16px / 4) rgb(147, 161, 169);\n box-shadow: var(--shadow-focus);\n}\n";
30
+ var styles$5 = {"search":"MIyb-oFZg9w-","searchInput":"WZPK91I4aJs-","clearSearch":"_7loHrVUe-Rk-"};
31
+ styleInject_es.styleInject(css_248z$5);
32
+
33
+ function ComboboxContentSearch(props) {
34
+ const searchRef = React.useRef(null);
35
+ React.useEffect(() => {
36
+ if (props.open) {
37
+ setTimeout(() => {
38
+ var _a;
39
+ (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
40
+ }, 0);
41
+ }
42
+ }, [props.open]);
43
+ return (React__default["default"].createElement("div", { className: styles$5.search },
44
+ React__default["default"].createElement("input", { type: "search", ref: searchRef, className: styles$5.searchInput, placeholder: props.placeholder ? `Search ${props.placeholder}` : "Search", onChange: (event) => handleSearch(event), value: props.searchValue }),
45
+ props.searchValue && (React__default["default"].createElement("button", { className: styles$5.clearSearch, onClick: clearSearch, type: "button", "data-testid": "ATL-Combobox-Content-Search-Clear", "aria-label": "Clear search" },
46
+ React__default["default"].createElement(Icon.Icon, { name: "remove", size: "small" })))));
47
+ function clearSearch() {
48
+ var _a;
49
+ props.setSearchValue("");
50
+ (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
51
+ }
52
+ function handleSearch(event) {
53
+ props.setSearchValue(event.target.value);
54
+ }
55
+ }
56
+
57
+ var css_248z$4 = ".SgMzjOcdE-E- {\n position: relative;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n}\n\n.TwoTCjgcssc- {\n display: -ms-flexbox;\n display: flex;\n max-height: calc((16px / 2) * 33.33);\n max-height: calc(calc(16px / 2) * 33.33);\n max-height: calc(var(--space-small) * 33.33);\n margin: 0;\n padding: 0;\n overflow: scroll;\n list-style: none;\n -ms-flex-direction: column;\n flex-direction: column;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n\n._8T5M7MGwCRE-,\n._4y5NXkNeIQM- {\n padding: calc(16px / 2) calc(16px * 1);\n padding: var(--space-small) var(--space-base);\n}\n\n.SgMzjOcdE-E-::after {\n content: \"\";\n display: block;\n position: absolute;\n right: 0;\n bottom: calc(16px / 2);\n bottom: var(--space-small);\n left: 0;\n height: calc(16px * 1);\n height: var(--space-base);\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, 0) 0%,\n rgb(255, 255, 255) 100%\n );\n pointer-events: none;\n}\n\n.SgMzjOcdE-E-::before {\n content: \"\";\n display: block;\n position: absolute;\n top: calc(16px / 2);\n top: var(--space-small);\n right: 0;\n left: 0;\n height: calc(16px * 1);\n height: var(--space-base);\n background: linear-gradient(\n to bottom,\n rgba(255, 255, 255, 1),\n rgba(255, 255, 255, 0)\n );\n pointer-events: none;\n}\n";
58
+ var styles$4 = {"container":"SgMzjOcdE-E-","optionsList":"TwoTCjgcssc-","filterMessage":"_8T5M7MGwCRE-","emptyStateMessage":"_4y5NXkNeIQM-"};
59
+ styleInject_es.styleInject(css_248z$4);
60
+
61
+ var css_248z$3 = "._5QdRGmaNHvc- {\n display: -ms-flexbox;\n display: flex;\n min-height: calc((calc(16px * 3) - calc(16px / 4)));\n min-height: calc((var(--space-largest) - var(--space-smaller)));\n box-sizing: border-box;\n margin: 0 calc(16px / 2);\n margin: 0 var(--space-small);\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-radius: calc(16px / 4);\n border-radius: var(--radius-large);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n font-weight: 500;\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: center;\n align-items: center;\n}\n\n._5QdRGmaNHvc-:hover,\n._5QdRGmaNHvc-:focus {\n background-color: rgb(238, 240, 242);\n background-color: var(--color-surface--background);\n}\n\n._5QdRGmaNHvc-:focus {\n box-shadow: 0px 0px 0px calc(16px / 8) rgba(255, 255, 255, 1),\n 0px 0px 0px calc(16px / 4) rgb(147, 161, 169);\n box-shadow: var(--shadow-focus);\n}\n";
62
+ var styles$3 = {"option":"_5QdRGmaNHvc-"};
63
+ styleInject_es.styleInject(css_248z$3);
64
+
65
+ const ComboboxContext = React__default["default"].createContext({});
66
+ function ComboboxContextProvider(props) {
67
+ return (React__default["default"].createElement(ComboboxContext.Provider, { value: {
68
+ open: props.open,
69
+ setOpen: props.setOpen,
70
+ selected: props.selected,
71
+ selectionHandler: props.selectionHandler,
72
+ handleClose: props.handleClose,
73
+ shouldScroll: props.shouldScroll,
74
+ } }, props.children));
75
+ }
76
+
77
+ function ComboboxOption(props) {
78
+ const { selected, selectionHandler } = React.useContext(ComboboxContext);
79
+ const isSelected = selected.some(selection => selection.id.toString() === props.id.toString());
80
+ return (React__default["default"].createElement("li", { key: props.id, tabIndex: -1, "data-selected": isSelected, role: "option", "aria-selected": isSelected, onClick: () => selectionHandler &&
81
+ selectionHandler({ id: props.id, label: props.label }), className: classnames__default["default"](styles$3.option) },
82
+ props.label,
83
+ isSelected && React__default["default"].createElement(Icon.Icon, { name: "checkmark", color: "blue" })));
84
+ }
85
+
86
+ function ComboboxContentList(props) {
87
+ return (React__default["default"].createElement("div", { className: styles$4.container },
88
+ !props.showEmptyState && props.options.length > 0 && (React__default["default"].createElement("ul", { className: styles$4.optionsList, role: "listbox", "aria-multiselectable": props.multiselect, ref: props.optionsListRef }, !props.showEmptyState &&
89
+ props.options.map(option => {
90
+ return (React__default["default"].createElement(ComboboxOption, { key: option.id, id: option.id, label: option.label }));
91
+ }))),
92
+ !props.showEmptyState && props.options.length === 0 && (React__default["default"].createElement("div", { className: styles$4.filterMessage },
93
+ React__default["default"].createElement(Text.Text, { variation: "subdued" },
94
+ "No results for ",
95
+ `“${props.searchValue}”`))),
96
+ props.showEmptyState && (React__default["default"].createElement("div", { className: styles$4.emptyStateMessage },
97
+ React__default["default"].createElement(Text.Text, { variation: "subdued" }, getZeroIndexStateText(props.subjectNoun))))));
98
+ }
99
+ function getZeroIndexStateText(subjectNoun) {
100
+ if (subjectNoun) {
101
+ return `You don't have any ${subjectNoun} yet`;
102
+ }
103
+ return "No options yet";
104
+ }
105
+
106
+ var css_248z$2 = ".Q-mwo-g5Fi8- {\n display: -ms-flexbox;\n display: flex;\n padding: calc(16px * 1) calc(16px / 2) 0 calc(16px * 1);\n padding: var(--space-base) var(--space-small) 0 var(--space-base);\n -ms-flex-pack: justify;\n justify-content: space-between;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n";
107
+ var styles$2 = {"header":"Q-mwo-g5Fi8-"};
108
+ styleInject_es.styleInject(css_248z$2);
109
+
110
+ function ComboboxContentHeader(props) {
111
+ const hasSelected = props.selectedCount > 0;
112
+ const actionLabel = hasSelected ? "Clear" : "Select all";
113
+ const label = getLabel(hasSelected, props.selectedCount, props.subjectNoun);
114
+ const handleSelectAll = hasSelected ? props.onClearAll : props.onSelectAll;
115
+ const showAction = hasSelected || props.hasOptionsVisible;
116
+ return (React__default["default"].createElement("div", { className: styles$2.header, "data-testid": "ATL-Combobox-Header" },
117
+ React__default["default"].createElement(Typography.Typography, { textColor: "heading", fontWeight: "semiBold" }, label),
118
+ showAction && (React__default["default"].createElement(Button.Button, { size: "small", label: actionLabel, type: "tertiary", onClick: handleSelectAll }))));
119
+ }
120
+ function getLabel(hasSelected, count, subjectNoun) {
121
+ if (hasSelected) {
122
+ return `${count} selected`;
123
+ }
124
+ if (subjectNoun) {
125
+ return `Select ${subjectNoun}`;
126
+ }
127
+ return "Select";
128
+ }
129
+
130
+ function useComboboxContent(options, open, selected, searchValue) {
131
+ const { shouldScroll } = React.useContext(ComboboxContext);
132
+ const optionsListRef = React.useRef(null);
133
+ const filteredOptions = options.filter(option => option.label.toLowerCase().includes(searchValue.toLowerCase()));
134
+ React.useEffect(() => {
135
+ var _a;
136
+ if (open && shouldScroll.current && optionsListRef.current) {
137
+ const firstSelected = Array.from((_a = optionsListRef === null || optionsListRef === void 0 ? void 0 : optionsListRef.current) === null || _a === void 0 ? void 0 : _a.children).find(child => {
138
+ if (child instanceof HTMLElement) {
139
+ return child.dataset.selected === "true";
140
+ }
141
+ });
142
+ scrollToFirstSelected(firstSelected, shouldScroll);
143
+ }
144
+ }, [open, selected]);
145
+ return {
146
+ filteredOptions,
147
+ optionsListRef,
148
+ };
149
+ }
150
+ function scrollToFirstSelected(firstSelected, shouldScroll) {
151
+ if (firstSelected) {
152
+ firstSelected.scrollIntoView({
153
+ block: "nearest",
154
+ });
155
+ shouldScroll.current = false;
156
+ }
157
+ }
158
+
159
+ // eslint-disable-next-line max-statements
160
+ function useComboboxAccessibility(selectionCallback, filteredOptions, optionsListRef, open, wrapperRef) {
161
+ const { handleClose } = React.useContext(ComboboxContext);
162
+ const hasOptionsVisible = open && filteredOptions.length > 0;
163
+ const focusedIndex = React.useRef(null);
164
+ useRefocusOnActivator.useRefocusOnActivator(open);
165
+ const popperRef = useFocusTrap.useFocusTrap(open);
166
+ const { styles: popperStyles, attributes, update, } = reactPopper.usePopper(wrapperRef.current, popperRef.current, {
167
+ modifiers: [
168
+ {
169
+ name: "flip",
170
+ options: {
171
+ fallbackPlacements: ["top-start"],
172
+ },
173
+ },
174
+ ],
175
+ placement: "bottom-start",
176
+ });
177
+ React.useEffect(() => {
178
+ focusedIndex.current = null;
179
+ if (open) {
180
+ update === null || update === void 0 ? void 0 : update();
181
+ }
182
+ }, [open, filteredOptions.length]);
183
+ React.useEffect(() => {
184
+ var _a;
185
+ if (open) {
186
+ (_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener("keydown", handleContentKeydown);
187
+ }
188
+ return () => {
189
+ var _a;
190
+ (_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", handleContentKeydown);
191
+ };
192
+ }, [open, optionsListRef, filteredOptions]);
193
+ useOnKeyDown.useOnKeyDown(() => {
194
+ if (open) {
195
+ handleClose();
196
+ }
197
+ }, "Escape");
198
+ function handleContentKeydown(event) {
199
+ var _a;
200
+ if (!hasOptionsVisible)
201
+ return;
202
+ if (event.key === "Enter" || event.key === " ") {
203
+ const activeElementInList = (_a = optionsListRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);
204
+ if (!activeElementInList)
205
+ return;
206
+ handleKeyboardSelection(event);
207
+ }
208
+ if (event.key === "ArrowDown") {
209
+ handleKeyboardNavigation(event, 1);
210
+ }
211
+ if (event.key === "ArrowUp") {
212
+ handleKeyboardNavigation(event, -1);
213
+ }
214
+ }
215
+ function handleKeyboardNavigation(event, indexChange) {
216
+ var _a;
217
+ const newIndex = focusedIndex.current === null ? 0 : focusedIndex.current + indexChange;
218
+ if (newIndex < 0 || newIndex >= filteredOptions.length)
219
+ return;
220
+ const optionElement = (_a = optionsListRef.current) === null || _a === void 0 ? void 0 : _a.children[newIndex];
221
+ optionElement === null || optionElement === void 0 ? void 0 : optionElement.focus();
222
+ focusedIndex.current = newIndex;
223
+ event.preventDefault();
224
+ event.stopPropagation();
225
+ }
226
+ function handleKeyboardSelection(event) {
227
+ event.preventDefault();
228
+ event.stopPropagation();
229
+ if (focusedIndex.current !== null) {
230
+ selectionCallback(filteredOptions[focusedIndex.current]);
231
+ }
232
+ }
233
+ return {
234
+ popperRef,
235
+ popperStyles,
236
+ attributes,
237
+ };
238
+ }
239
+
240
+ function ComboboxContent(props) {
241
+ const optionsExist = props.options.length > 0;
242
+ const { filteredOptions, optionsListRef } = useComboboxContent(props.options, props.open, props.selected, props.searchValue);
243
+ const { popperRef, popperStyles, attributes } = useComboboxAccessibility(props.handleSelection, filteredOptions, optionsListRef, props.open, props.wrapperRef);
244
+ const template = (React__default["default"].createElement("div", Object.assign({ ref: popperRef, id: "ATL-Combobox-Content", "data-testid": "ATL-Combobox-Content", tabIndex: 0, className: classnames__default["default"](styles$6.content, { [styles$6.hidden]: !props.open }), style: popperStyles.popper }, attributes.popper),
245
+ React__default["default"].createElement(ComboboxContentSearch, { open: props.open, placeholder: props.subjectNoun, searchValue: props.searchValue, setSearchValue: props.setSearchValue }),
246
+ props.multiselect && optionsExist && (React__default["default"].createElement(ComboboxContentHeader, { hasOptionsVisible: filteredOptions.length > 0, subjectNoun: props.subjectNoun, selectedCount: props.selected.length, onClearAll: () => {
247
+ props.selectedStateSetter([]);
248
+ }, onSelectAll: () => {
249
+ props.selectedStateSetter(filteredOptions);
250
+ } })),
251
+ React__default["default"].createElement(ComboboxContentList, { multiselect: props.multiselect, showEmptyState: !optionsExist, options: filteredOptions, selected: props.selected, optionsListRef: optionsListRef, searchValue: props.searchValue, subjectNoun: props.subjectNoun }),
252
+ props.actionElements && (React__default["default"].createElement("div", { className: styles$6.actions, role: "group" }, props.actionElements.map((child, index, childrenArray) => (React__default["default"].createElement("div", { key: index, className: classnames__default["default"]({
253
+ [styles$6.actionPadding]: index === childrenArray.length - 1,
254
+ }) }, child)))))));
255
+ return ReactDOM__default["default"].createPortal(template, document.body);
256
+ }
257
+
258
+ var css_248z$1 = ".Ow9wSNnGP-g- {\n width: 100%;\n box-sizing: border-box;\n padding: 0 calc(16px / 2);\n padding: 0 var(--space-small);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.ncp0nKHQ7d8- {\n position: relative;\n width: 100%;\n min-height: calc((calc(16px * 3) - calc(16px / 2)));\n min-height: calc((var(--space-largest) - var(--space-small)));\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n border: none;\n border-radius: calc(16px / 4);\n border-radius: var(--radius-large);\n text-align: left;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n}\n\n.ncp0nKHQ7d8-:focus {\n box-shadow: 0px 0px 0px calc(16px / 8) rgba(255, 255, 255, 1),\n 0px 0px 0px calc(16px / 4) rgb(147, 161, 169);\n box-shadow: var(--shadow-focus);\n background-color: rgb(238, 240, 242);\n background-color: var(--color-surface--background);\n}\n\n.ncp0nKHQ7d8-:hover {\n background-color: rgb(238, 240, 242);\n background-color: var(--color-surface--background);\n}\n\n.ncp0nKHQ7d8- span {\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n}\n";
259
+ var styles$1 = {"actionContainer":"Ow9wSNnGP-g-","actionButton":"ncp0nKHQ7d8-"};
260
+ styleInject_es.styleInject(css_248z$1);
261
+
262
+ function ComboboxAction(props) {
263
+ return (React__default["default"].createElement("div", { className: styles$1.actionContainer },
264
+ React__default["default"].createElement("button", { className: styles$1.actionButton, onClick: props.onClick, type: "button", "aria-label": props.label },
265
+ React__default["default"].createElement(Typography.Typography, { element: "span", size: "base", textColor: "green", fontWeight: "semiBold" }, props.label))));
266
+ }
267
+
268
+ function ComboboxTrigger({ label = "Select", selected, }) {
269
+ const { handleClose, open, setOpen } = React__default["default"].useContext(ComboboxContext);
270
+ const hasSelection = selected.length;
271
+ const selectedLabel = selected.map(option => option.label).join(", ");
272
+ return (React__default["default"].createElement(Chip.Chip, { variation: hasSelection ? "base" : "subtle", label: hasSelection ? selectedLabel : "", heading: label, onClick: () => {
273
+ if (open) {
274
+ handleClose();
275
+ }
276
+ else {
277
+ setOpen(true);
278
+ }
279
+ }, role: "combobox" }, !hasSelection && (React__default["default"].createElement(Chip.Chip.Suffix, null,
280
+ React__default["default"].createElement(Icon.Icon, { name: "add", size: "small" })))));
281
+ }
282
+
283
+ var css_248z = ".W8qMZnORYxI- {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 6;\n z-index: var(--elevation-menu);\n background-color: transparent;\n}\n\n._-0dkolvLF-Y- {\n display: inline-block;\n}\n";
284
+ var styles = {"overlay":"W8qMZnORYxI-","wrapper":"_-0dkolvLF-Y-"};
285
+ styleInject_es.styleInject(css_248z);
286
+
287
+ function useMakeComboboxHandlers(setOpen, setSearchValue, selectedOptions, shouldScroll, selectedStateSetter, multiSelect, onClose) {
288
+ const handleClose = React.useCallback(() => {
289
+ setOpen(false);
290
+ setSearchValue("");
291
+ onClose && onClose();
292
+ if (selectedOptions.length > 0) {
293
+ shouldScroll.current = true;
294
+ }
295
+ }, [setOpen, setSearchValue, onClose, selectedOptions.length]);
296
+ const handleSelection = React.useCallback((selection) => {
297
+ if (multiSelect) {
298
+ handleMultiSelect(selectedStateSetter, selectedOptions, selection);
299
+ }
300
+ else {
301
+ handleSingleSelect(selectedStateSetter, selection);
302
+ }
303
+ }, [multiSelect, selectedStateSetter, selectedOptions]);
304
+ const handleSingleSelect = React.useCallback((selectCallback, selection) => {
305
+ selectCallback([selection]);
306
+ handleClose();
307
+ }, []);
308
+ return {
309
+ handleClose,
310
+ handleSelection,
311
+ };
312
+ }
313
+ function handleMultiSelect(selectCallback, selected, selection) {
314
+ if (selected.some(s => s.id === selection.id)) {
315
+ selectCallback(selected.filter(s => s.id !== selection.id));
316
+ }
317
+ else {
318
+ selectCallback([...selected, selection]);
319
+ }
320
+ }
321
+
322
+ function useCombobox(selected, onSelect, onClose, multiSelect) {
323
+ const wrapperRef = React.useRef(null);
324
+ const shouldScroll = React.useRef(false);
325
+ const [open, setOpen] = React.useState(false);
326
+ const [searchValue, setSearchValue] = React.useState("");
327
+ const { handleClose, handleSelection } = useMakeComboboxHandlers(setOpen, setSearchValue, selected, shouldScroll, onSelect, multiSelect, onClose);
328
+ return {
329
+ wrapperRef,
330
+ searchValue,
331
+ setSearchValue,
332
+ open,
333
+ setOpen,
334
+ selectedOptions: selected,
335
+ selectedStateSetter: onSelect,
336
+ shouldScroll,
337
+ handleClose,
338
+ handleSelection,
339
+ };
340
+ }
341
+
342
+ function ComboboxActivator(props) {
343
+ const { handleClose, open, setOpen } = React__default["default"].useContext(ComboboxContext);
344
+ if (props.children.type === Button.Button || props.children.type === Chip.Chip) {
345
+ return React__default["default"].cloneElement(props.children, {
346
+ role: "combobox",
347
+ onClick: () => {
348
+ if (open) {
349
+ handleClose();
350
+ }
351
+ else {
352
+ setOpen(true);
353
+ }
354
+ },
355
+ });
356
+ }
357
+ return props.children;
358
+ }
359
+
360
+ const COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = "Combobox must have exactly one Trigger element";
361
+ function useComboboxValidation(children) {
362
+ const optionElements = getCompoundComponents(ComboboxOption, children);
363
+ const actionElements = getCompoundComponents(ComboboxAction, children);
364
+ const activatorElements = getCompoundComponents(ComboboxActivator, children);
365
+ const shouldThrowTriggerError = isInvalid(activatorElements);
366
+ useAssert.useAssert(shouldThrowTriggerError, COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE);
367
+ return {
368
+ optionElements,
369
+ triggerElement: activatorElements[0],
370
+ actionElements,
371
+ };
372
+ }
373
+ function isInvalid(activators) {
374
+ return activators.length > 1 ? true : false;
375
+ }
376
+ /**
377
+ * Return all instances child component that matches the `type` provided
378
+ */
379
+ function getCompoundComponents(type, children) {
380
+ const childrenArray = React.Children.toArray(children);
381
+ const elements = childrenArray.filter((child) => React.isValidElement(child) && child.type === type);
382
+ return elements;
383
+ }
384
+
385
+ function Combobox(props) {
386
+ const { optionElements, triggerElement, actionElements } = useComboboxValidation(props.children);
387
+ const options = React.useMemo(() => (optionElements === null || optionElements === void 0 ? void 0 : optionElements.map(option => ({
388
+ id: option.props.id,
389
+ label: option.props.label,
390
+ }))) || [], [optionElements]);
391
+ const { selectedOptions, selectedStateSetter, shouldScroll, wrapperRef, searchValue, setSearchValue, open, setOpen, handleClose, handleSelection, } = useCombobox(props.selected, props.onSelect, props.onClose, props.multiSelect);
392
+ return (React__default["default"].createElement(ComboboxContextProvider, { selected: selectedOptions, selectionHandler: handleSelection, open: open, setOpen: setOpen, handleClose: handleClose, shouldScroll: shouldScroll },
393
+ React__default["default"].createElement("div", { ref: wrapperRef, className: styles.wrapper },
394
+ open && (React__default["default"].createElement("div", { className: styles.overlay, onClick: () => handleClose(), "data-testid": "ATL-Combobox-Overlay" })),
395
+ triggerElement || (React__default["default"].createElement(ComboboxTrigger, { label: props.label, selected: props.selected })),
396
+ React__default["default"].createElement(ComboboxContent, { multiselect: props.multiSelect, searchPlaceholder: props.searchPlaceholder, subjectNoun: props.subjectNoun, selected: selectedOptions, actionElements: actionElements, selectedStateSetter: selectedStateSetter, handleSelection: handleSelection, searchValue: searchValue, setSearchValue: setSearchValue, wrapperRef: wrapperRef, open: open, setOpen: setOpen, options: options }))));
397
+ }
398
+ Combobox.Activator = ComboboxActivator;
399
+ Combobox.Action = ComboboxAction;
400
+ Combobox.Option = ComboboxOption;
401
+
402
+ exports.Combobox = Combobox;
403
+ exports.ComboboxContextProvider = ComboboxContextProvider;
@@ -2,28 +2,28 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ConfirmationModal = require('../ConfirmationModal-6b61ebf5.js');
5
+ var ConfirmationModal = require('../ConfirmationModal-f7234e44.js');
6
6
  require('react');
7
7
  require('@jobber/hooks/useOnKeyDown');
8
- require('../Modal-a9ab9565.js');
8
+ require('../Modal-b9d194e4.js');
9
9
  require('react-dom');
10
10
  require('classnames');
11
11
  require('framer-motion');
12
12
  require('@jobber/hooks/useRefocusOnActivator');
13
13
  require('@jobber/hooks/useFocusTrap');
14
14
  require('../style-inject.es-9d2f5f4e.js');
15
- require('../Heading-a1191b15.js');
16
- require('../Typography-fd6f932a.js');
17
- require('../Button-fd8413b2.js');
15
+ require('../Heading-0f4ecb0c.js');
16
+ require('../Typography-973b122e.js');
17
+ require('../Button-163a0641.js');
18
18
  require('react-router-dom');
19
19
  require('../Icon-405a216c.js');
20
20
  require('@jobber/design');
21
- require('../ButtonDismiss-82680c7d.js');
21
+ require('../ButtonDismiss-2b98d075.js');
22
22
  require('../Content-2ca1ffe1.js');
23
- require('../Markdown-f6748dcb.js');
23
+ require('../Markdown-96070121.js');
24
24
  require('react-markdown');
25
- require('../Text-e7ed0974.js');
26
- require('../Emphasis-76a10790.js');
25
+ require('../Text-4a2bc89f.js');
26
+ require('../Emphasis-b2d1b3aa.js');
27
27
 
28
28
 
29
29
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  var React = require('react');
4
4
  var useOnKeyDown = require('@jobber/hooks/useOnKeyDown');
5
- var Modal = require('./Modal-a9ab9565.js');
5
+ var Modal = require('./Modal-b9d194e4.js');
6
6
  var Content = require('./Content-2ca1ffe1.js');
7
- var Markdown = require('./Markdown-f6748dcb.js');
7
+ var Markdown = require('./Markdown-96070121.js');
8
8
 
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
@@ -12,7 +12,7 @@ interface ContentProps {
12
12
  * Change the wrapping element to be one of the available
13
13
  * semantic tags.
14
14
  *
15
- * @default 'div'
15
+ * @default "div"
16
16
  */
17
17
  readonly type?: "section" | "aside" | "header" | "footer" | "article" | "main" | "div";
18
18
  }
@@ -3,18 +3,18 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var Card = require('../Card-cc2ffbaa.js');
6
+ var Card = require('../Card-3178033c.js');
7
7
  var Content = require('../Content-2ca1ffe1.js');
8
- var Emphasis = require('../Emphasis-76a10790.js');
8
+ var Emphasis = require('../Emphasis-b2d1b3aa.js');
9
9
  require('classnames');
10
10
  require('../style-inject.es-9d2f5f4e.js');
11
- require('../Heading-a1191b15.js');
12
- require('../Typography-fd6f932a.js');
13
- require('../Button-fd8413b2.js');
11
+ require('../Heading-0f4ecb0c.js');
12
+ require('../Typography-973b122e.js');
13
+ require('../Button-163a0641.js');
14
14
  require('react-router-dom');
15
15
  require('../Icon-405a216c.js');
16
16
  require('@jobber/design');
17
- require('../Menu-51f8712f.js');
17
+ require('../Menu-d7ea093c.js');
18
18
  require('uuid');
19
19
  require('framer-motion');
20
20
  require('@jobber/hooks/useOnKeyDown');
@@ -3,15 +3,22 @@ import { DataListLayout } from "./components/DataListLayout";
3
3
  import { DataListFilters } from "./components/DataListFilters";
4
4
  import { DataListSearch } from "./components/DataListSearch";
5
5
  import { DataListEmptyState } from "./components/DataListEmptyState";
6
- import { DataListObject, DataListProps } from "./DataList.types";
7
6
  import { DataListItemActions } from "./components/DataListItemActions";
8
7
  import { DataListAction } from "./components/DataListAction";
9
- export declare function DataList<T extends DataListObject>({ sorting, ...props }: DataListProps<T>): JSX.Element;
8
+ import { DataListLayoutActions } from "./components/DataListLayoutActions";
9
+ import { DataListBulkActionProps, DataListObject, DataListProps } from "./DataList.types";
10
+ import { DataListBulkActions } from "./components/DataListBulkActions";
11
+ import { DataListStatusBar } from "./components/DataListStatusBar";
12
+ export declare function DataList<T extends DataListObject>({ selected, sorting, ...props }: DataListProps<T>): JSX.Element;
10
13
  export declare namespace DataList {
11
14
  var Layout: typeof DataListLayout;
15
+ var LayoutActions: typeof DataListLayoutActions;
12
16
  var EmptyState: typeof DataListEmptyState;
13
17
  var Filters: typeof DataListFilters;
14
18
  var Search: typeof DataListSearch;
15
19
  var ItemActions: typeof DataListItemActions;
16
- var Action: typeof DataListAction;
20
+ var BulkActions: typeof DataListBulkActions;
21
+ var ItemAction: typeof DataListAction;
22
+ var BatchAction: (props: DataListBulkActionProps) => JSX.Element;
23
+ var StatusBar: typeof DataListStatusBar;
17
24
  }
@@ -1,5 +1,6 @@
1
1
  import { ReactElement, ReactNode } from "react";
2
2
  import { IconNames } from "@jobber/design";
3
+ import { XOR } from "ts-xor";
3
4
  import { Breakpoints } from "./DataList.const";
4
5
  import { ButtonProps } from "../Button";
5
6
  export { Breakpoints } from "./DataList.const";
@@ -101,8 +102,9 @@ export interface DataListProps<T extends DataListObject> {
101
102
  readonly selected?: T["id"][];
102
103
  readonly onSelectAll?: () => void;
103
104
  }
105
+ export type LayoutRenderer<T extends DataListObject> = (item: DataListItemType<T[]>) => JSX.Element;
104
106
  export interface DataListLayoutProps<T extends DataListObject> {
105
- readonly children: (item: DataListItemType<T[]>) => JSX.Element;
107
+ readonly children: LayoutRenderer<T>;
106
108
  /**
107
109
  * The breakpoint at which the layout should be displayed. It will be rendered until a layout with a larger breakpoint is found.
108
110
  * @default "xs"
@@ -115,7 +117,15 @@ export interface DataListSearchProps {
115
117
  * prepended by "Search" or just falls back to "Search".
116
118
  */
117
119
  readonly placeholder?: string;
118
- readonly onSearch: (search: string) => void;
120
+ /**
121
+ * The initial value of the search input.
122
+ *
123
+ * Updating this prop after the component has mounted will rerender the
124
+ * component with the new value. Only update the value of this when you
125
+ * absolutely have to.
126
+ */
127
+ readonly initialValue?: string;
128
+ readonly onSearch: (value: string) => void;
119
129
  }
120
130
  export interface DataListFiltersProps {
121
131
  readonly children: ReactElement | ReactElement[];
@@ -147,15 +157,61 @@ export interface DataListContextProps<T extends DataListObject> extends DataList
147
157
  readonly emptyStateComponents?: ReactElement<DataListEmptyStateProps>[];
148
158
  readonly layoutComponents?: ReactElement<DataListLayoutProps<T>>[];
149
159
  readonly itemActionComponent?: ReactElement<DataListItemActionsProps<T>>;
160
+ readonly bulkActionsComponent?: ReactElement<DataListItemActionsProps<T>>;
161
+ readonly layoutBreakpoints: Breakpoints[];
162
+ readonly registerLayoutBreakpoints: (breakpoint: Breakpoints) => void;
163
+ readonly layouts: {
164
+ readonly [Breakpoint in Breakpoints]?: LayoutRenderer<T>;
165
+ };
166
+ readonly registerLayout: (size: Breakpoints, layout: LayoutRenderer<T>) => void;
167
+ }
168
+ export interface DataListLayoutContextProps {
169
+ readonly isInLayoutProvider: boolean;
170
+ /**
171
+ * Determine if the consumer of the DataList manually added an action to the
172
+ * layout. This is used to determine if the DataList should render the
173
+ * action column.
174
+ */
175
+ readonly hasInLayoutActions: boolean;
176
+ readonly setHasInLayoutActions: (state: boolean) => void;
177
+ }
178
+ export interface DataListLayoutActionsContextProps<T extends DataListObject> {
179
+ readonly activeItem?: T;
150
180
  }
151
181
  type Fragment<T> = T | T[];
152
- export interface DataListItemActionsProps<T extends DataListObject> {
182
+ interface BaseDataListItemActionsProps<T extends DataListObject> {
153
183
  /**
154
184
  * The actions to render for each item in the DataList. This only accepts the
155
185
  * DataList.Action component.
156
186
  */
157
187
  readonly children?: Fragment<ReactElement<DataListActionProps<T>>>;
188
+ /**
189
+ * Callback when an item is clicked.
190
+ */
191
+ readonly onClick?: (item: T) => void;
192
+ }
193
+ export interface DataListBulkActionsProps {
194
+ /**
195
+ * The actions to render on the top of the DataList to make actions to multiple items.
196
+ * This only accepts the DataList.BatchAction component.
197
+ */
198
+ readonly children?: Fragment<ReactElement<DataListBulkActionProps>>;
199
+ }
200
+ interface DataListItemActionsPropsWithURL<T extends DataListObject> extends BaseDataListItemActionsProps<T> {
201
+ /**
202
+ * If a normal page navigation is needed, use this prop to change the element
203
+ * to an `a` tag with an `href`.
204
+ */
205
+ readonly url?: string | ((item: T) => string);
158
206
  }
207
+ interface DataListItemActionsPropsWithTo<T extends DataListObject> extends BaseDataListItemActionsProps<T> {
208
+ /**
209
+ * If a React Navigation is needed, use this prop to use the `Link` component
210
+ * that comes with React Router.
211
+ */
212
+ readonly to?: string | ((item: T) => string);
213
+ }
214
+ export type DataListItemActionsProps<T extends DataListObject> = XOR<DataListItemActionsPropsWithURL<T>, DataListItemActionsPropsWithTo<T>>;
159
215
  export interface DataListActionProps<T extends DataListObject> {
160
216
  /**
161
217
  * The label of the action
@@ -169,11 +225,30 @@ export interface DataListActionProps<T extends DataListObject> {
169
225
  * Adjust the styling of an action label and icon to be more destructive.
170
226
  */
171
227
  readonly destructive?: boolean;
228
+ /**
229
+ * Determine if the action is visible for a given item.
230
+ */
231
+ readonly visible?: (item: T) => boolean;
172
232
  /**
173
233
  * The callback function when the action is clicked.
174
234
  */
175
235
  readonly onClick?: (data: T) => void;
176
236
  }
177
- export interface InternalDataListActionProps<T extends DataListObject> extends DataListActionProps<T> {
178
- readonly item: T;
237
+ export interface DataListActionsProps<T extends DataListObject> {
238
+ /**
239
+ * The actions to render for each item in the DataList. This only accepts the
240
+ * DataList.Action component.
241
+ */
242
+ readonly children?: Fragment<ReactElement<DataListActionProps<T>>>;
243
+ /**
244
+ * The number of items to expose before the "More" button is shown.
245
+ * @default 2
246
+ */
247
+ readonly itemsToExpose?: number;
248
+ }
249
+ export interface DataListBulkActionProps extends Omit<DataListActionProps<DataListObject>, "visible"> {
250
+ /**
251
+ * The callback function when the action is clicked.
252
+ */
253
+ readonly onClick?: () => void;
179
254
  }