@sproutsocial/racine 22.5.1 → 23.0.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 (168) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/__flow__/Toast/Toast.flow.js +4 -0
  3. package/commonjs/Avatar/Avatar.js +24 -16
  4. package/commonjs/Badge/Badge.js +20 -13
  5. package/commonjs/Banner/Banner.js +35 -25
  6. package/commonjs/Box/Box.js +7 -2
  7. package/commonjs/Breadcrumb/Breadcrumb.js +36 -23
  8. package/commonjs/Button/Button.js +11 -3
  9. package/commonjs/Card/Card.js +25 -18
  10. package/commonjs/Card/subComponents.js +32 -15
  11. package/commonjs/CharacterCounter/CharacterCounter.js +7 -3
  12. package/commonjs/ChartLegend/ChartLegend.js +10 -3
  13. package/commonjs/ChartLegend/useChartLabels.js +12 -10
  14. package/commonjs/Checkbox/Checkbox.js +55 -45
  15. package/commonjs/Checkbox/styles.js +20 -17
  16. package/commonjs/Collapsible/Collapsible.js +22 -16
  17. package/commonjs/DatePicker/DateRangePicker/DateRangePicker.js +26 -16
  18. package/commonjs/DatePicker/DateRangePicker/StatefulDateRangePicker.js +7 -2
  19. package/commonjs/DatePicker/SingleDatePicker/SingleDatePicker.js +24 -14
  20. package/commonjs/DatePicker/SingleDatePicker/StatefulSingleDatePicker.js +7 -2
  21. package/commonjs/DatePicker/common.js +8 -6
  22. package/commonjs/Drawer/Drawer.js +160 -113
  23. package/commonjs/EmptyState/EmptyState.js +44 -31
  24. package/commonjs/Fieldset/Fieldset.js +31 -14
  25. package/commonjs/FormField/FormField.js +37 -31
  26. package/commonjs/Icon/Icon.js +35 -30
  27. package/commonjs/Image/Image.js +5 -3
  28. package/commonjs/Indicator/Indicator.js +12 -6
  29. package/commonjs/Input/Input.js +57 -51
  30. package/commonjs/KeyboardKey/KeyboardKey.js +12 -3
  31. package/commonjs/Label/Label.js +15 -9
  32. package/commonjs/Link/Link.js +10 -3
  33. package/commonjs/Listbox/Listbox.js +16 -13
  34. package/commonjs/Loader/Loader.js +9 -3
  35. package/commonjs/LoaderButton/LoaderButton.js +28 -18
  36. package/commonjs/Menu/Menu.js +128 -107
  37. package/commonjs/Menu/utils/descendants.js +6 -6
  38. package/commonjs/Message/Message.js +79 -59
  39. package/commonjs/Modal/Modal.js +54 -31
  40. package/commonjs/Modal/styles.js +8 -4
  41. package/commonjs/Numeral/Numeral.js +27 -11
  42. package/commonjs/PartnerLogo/PartnerLogo.js +22 -12
  43. package/commonjs/Radio/Radio.js +28 -22
  44. package/commonjs/SegmentedControl/SegmentedControl.js +38 -24
  45. package/commonjs/Select/Select.js +32 -25
  46. package/commonjs/SpotIllustration/SpotIllustration.js +13 -5
  47. package/commonjs/Stack/Stack.js +15 -8
  48. package/commonjs/Switch/Switch.js +14 -7
  49. package/commonjs/Table/Table.js +65 -45
  50. package/commonjs/TableCell/TableCell.js +6 -3
  51. package/commonjs/TableHeaderCell/TableHeaderCell.js +20 -12
  52. package/commonjs/TableRowAccordion/TableRowAccordion.js +35 -29
  53. package/commonjs/Tabs/Tabs.js +37 -30
  54. package/commonjs/Text/Text.js +10 -3
  55. package/commonjs/Textarea/Textarea.js +37 -32
  56. package/commonjs/ThemeProvider/index.js +8 -5
  57. package/commonjs/Toast/Toast.js +127 -91
  58. package/commonjs/Toast/index.js +15 -15
  59. package/commonjs/Toast/styles.js +56 -30
  60. package/commonjs/ToggleHint/ToggleHint.js +11 -5
  61. package/commonjs/Token/Token.js +39 -25
  62. package/commonjs/TokenInput/TokenInput.js +55 -47
  63. package/commonjs/TokenInput/TokenScreenReaderStatus.js +5 -3
  64. package/commonjs/Tooltip/Tooltip.js +34 -27
  65. package/dist/types/Drawer/Drawer.d.ts.map +1 -1
  66. package/dist/types/Drawer/DrawerTypes.d.ts +6 -3
  67. package/dist/types/Drawer/DrawerTypes.d.ts.map +1 -1
  68. package/dist/types/Listbox/ListboxTypes.d.ts +1 -1
  69. package/dist/types/Listbox/ListboxTypes.d.ts.map +1 -1
  70. package/dist/types/Menu/MenuTypes.d.ts +4 -4
  71. package/dist/types/Menu/MenuTypes.d.ts.map +1 -1
  72. package/dist/types/ThemeProvider/index.d.ts +1 -1
  73. package/dist/types/ThemeProvider/index.d.ts.map +1 -1
  74. package/dist/types/Toast/Toast.d.ts +23 -2
  75. package/dist/types/Toast/Toast.d.ts.map +1 -1
  76. package/dist/types/Toast/ToastTypes.d.ts +27 -13
  77. package/dist/types/Toast/ToastTypes.d.ts.map +1 -1
  78. package/dist/types/Toast/index.d.ts +2 -4
  79. package/dist/types/Toast/index.d.ts.map +1 -1
  80. package/dist/types/Toast/styles.d.ts +11 -15
  81. package/dist/types/Toast/styles.d.ts.map +1 -1
  82. package/dist/types/Tooltip/TooltipTypes.d.ts +2 -2
  83. package/dist/types/Tooltip/TooltipTypes.d.ts.map +1 -1
  84. package/dist/types/utils/react-testing-library.d.ts +61 -121
  85. package/dist/types/utils/react-testing-library.d.ts.map +1 -1
  86. package/lib/Avatar/Avatar.js +25 -16
  87. package/lib/Badge/Badge.js +22 -13
  88. package/lib/Banner/Banner.js +37 -25
  89. package/lib/Box/Box.js +8 -2
  90. package/lib/Breadcrumb/Breadcrumb.js +37 -23
  91. package/lib/Button/Button.js +11 -3
  92. package/lib/Card/Card.js +17 -8
  93. package/lib/Card/subComponents.js +35 -15
  94. package/lib/CharacterCounter/CharacterCounter.js +7 -3
  95. package/lib/ChartLegend/ChartLegend.js +11 -3
  96. package/lib/ChartLegend/useChartLabels.js +13 -10
  97. package/lib/Checkbox/Checkbox.js +56 -45
  98. package/lib/Checkbox/styles.js +20 -17
  99. package/lib/Collapsible/Collapsible.js +22 -16
  100. package/lib/DatePicker/DateRangePicker/DateRangePicker.js +29 -16
  101. package/lib/DatePicker/DateRangePicker/StatefulDateRangePicker.js +8 -2
  102. package/lib/DatePicker/SingleDatePicker/SingleDatePicker.js +27 -14
  103. package/lib/DatePicker/SingleDatePicker/StatefulSingleDatePicker.js +8 -2
  104. package/lib/DatePicker/common.js +8 -6
  105. package/lib/Drawer/Drawer.js +159 -111
  106. package/lib/EmptyState/EmptyState.js +46 -31
  107. package/lib/Fieldset/Fieldset.js +33 -14
  108. package/lib/FormField/FormField.js +38 -31
  109. package/lib/Icon/Icon.js +36 -30
  110. package/lib/Image/Image.js +5 -3
  111. package/lib/Indicator/Indicator.js +13 -6
  112. package/lib/Input/Input.js +57 -49
  113. package/lib/KeyboardKey/KeyboardKey.js +12 -3
  114. package/lib/Label/Label.js +16 -9
  115. package/lib/Link/Link.js +11 -3
  116. package/lib/Listbox/Listbox.js +17 -13
  117. package/lib/Loader/Loader.js +9 -3
  118. package/lib/LoaderButton/LoaderButton.js +30 -18
  119. package/lib/Menu/Menu.js +128 -104
  120. package/lib/Menu/utils/descendants.js +5 -4
  121. package/lib/Message/Message.js +80 -59
  122. package/lib/Modal/Modal.js +56 -31
  123. package/lib/Modal/styles.js +8 -2
  124. package/lib/Numeral/Numeral.js +30 -11
  125. package/lib/PartnerLogo/PartnerLogo.js +22 -12
  126. package/lib/Radio/Radio.js +29 -22
  127. package/lib/SegmentedControl/SegmentedControl.js +40 -24
  128. package/lib/Select/Select.js +33 -25
  129. package/lib/SpotIllustration/SpotIllustration.js +13 -5
  130. package/lib/Stack/Stack.js +17 -8
  131. package/lib/Switch/Switch.js +15 -7
  132. package/lib/Table/Table.js +65 -43
  133. package/lib/TableCell/TableCell.js +5 -2
  134. package/lib/TableHeaderCell/TableHeaderCell.js +20 -11
  135. package/lib/TableRowAccordion/TableRowAccordion.js +35 -28
  136. package/lib/Tabs/Tabs.js +37 -30
  137. package/lib/Text/Text.js +11 -3
  138. package/lib/Textarea/Textarea.js +37 -30
  139. package/lib/ThemeProvider/index.js +8 -3
  140. package/lib/Toast/Toast.js +130 -90
  141. package/lib/Toast/index.js +3 -5
  142. package/lib/Toast/styles.js +55 -26
  143. package/lib/ToggleHint/ToggleHint.js +12 -5
  144. package/lib/Token/Token.js +42 -25
  145. package/lib/TokenInput/TokenInput.js +56 -47
  146. package/lib/TokenInput/TokenScreenReaderStatus.js +5 -3
  147. package/lib/Tooltip/Tooltip.js +34 -27
  148. package/package.json +37 -33
  149. package/commonjs/Drawer/SlideTransition.js +0 -47
  150. package/commonjs/Popout/Popout.js +0 -313
  151. package/commonjs/Popout/PopoutTypes.js +0 -5
  152. package/commonjs/Popout/index.js +0 -30
  153. package/commonjs/Popout/styles.js +0 -13
  154. package/dist/types/Drawer/SlideTransition.d.ts +0 -15
  155. package/dist/types/Drawer/SlideTransition.d.ts.map +0 -1
  156. package/dist/types/Popout/Popout.d.ts +0 -14
  157. package/dist/types/Popout/Popout.d.ts.map +0 -1
  158. package/dist/types/Popout/PopoutTypes.d.ts +0 -90
  159. package/dist/types/Popout/PopoutTypes.d.ts.map +0 -1
  160. package/dist/types/Popout/index.d.ts +0 -5
  161. package/dist/types/Popout/index.d.ts.map +0 -1
  162. package/dist/types/Popout/styles.d.ts +0 -2
  163. package/dist/types/Popout/styles.d.ts.map +0 -1
  164. package/lib/Drawer/SlideTransition.js +0 -38
  165. package/lib/Popout/Popout.js +0 -303
  166. package/lib/Popout/PopoutTypes.js +0 -1
  167. package/lib/Popout/index.js +0 -4
  168. package/lib/Popout/styles.js +0 -6
@@ -1,90 +0,0 @@
1
- import * as React from "react";
2
- import type { PopperProps } from "react-popper";
3
- import type { TypeStyledComponentsCommonProps } from "../types/styled-components";
4
- import type { TypeSystemCommonProps, TypeSystemLayoutProps } from "@sproutsocial/seeds-react-system-props";
5
- export type EnumPlacements = "auto" | "top" | "right" | "bottom" | "left" | "top-start" | "right-start" | "bottom-start" | "left-start" | "top-end" | "right-end" | "bottom-end" | "left-end";
6
- export interface TypeFocusLockProps {
7
- disabled?: boolean;
8
- returnFocus?: boolean | {
9
- preventScroll?: boolean;
10
- };
11
- persistentFocus?: boolean;
12
- autoFocus?: boolean;
13
- noFocusGuards?: boolean | "tail";
14
- group?: string;
15
- className?: string;
16
- onActivation?: (node: HTMLElement) => void;
17
- onDeactivation?: (node: HTMLElement) => void;
18
- as?: TypeStyledComponentsCommonProps["as"];
19
- lockProps?: any;
20
- ref?: any;
21
- whiteList?: (activeElement: HTMLElement) => boolean;
22
- shards?: Array<any>;
23
- children?: React.ReactNode;
24
- }
25
- export interface TypePopoutProps extends TypeStyledComponentsCommonProps, TypeSystemCommonProps, TypeSystemLayoutProps, Omit<React.ComponentPropsWithoutRef<"div">, "color" | "children" | "content"> {
26
- /**
27
- * Whether Popout should automatically add aria-attributes to its wrapped elements
28
- */
29
- disableWrapperAria?: boolean;
30
- /**
31
- * Is the popout open? This prop is optional. By using it, you will lose some automatic handling of the logic for opening and closing the popout.
32
- */
33
- isOpen?: boolean;
34
- /**
35
- * If you use the isOpen prop you will need to pass a handler to change the state of the popout
36
- */
37
- setIsOpen?: (isOpen: boolean, event?: MouseEvent | KeyboardEvent) => void;
38
- /**
39
- * The content to be shown in the popout. If there is no content, just the children are rendered
40
- */
41
- content: (React.ReactElement<any> | null | undefined) | (((opts: {
42
- hide: () => void;
43
- }) => React.ReactElement<any>) | null | undefined);
44
- /**
45
- * The content that the popout should be attached to
46
- */
47
- children: React.ReactElement<any> | ((opts: {
48
- ref: (arg0: React.ElementRef<any> | HTMLElement) => void;
49
- toggle: () => void;
50
- show: () => void;
51
- hide: () => void;
52
- ariaProps: Record<string, any>;
53
- }) => React.ReactNode);
54
- /** How the popped-out content should be placed, in relationship to the children */
55
- placement?: EnumPlacements;
56
- /**
57
- * Should the popped-out content inherit its width from the children?
58
- * This is useful for typeaheads and other places where a popout needs to match the width of a given element.
59
- */
60
- fullWidth?: boolean;
61
- /**
62
- * When the popout has opened, should we focus on its content?
63
- * Focus will be brought inside by looking for elements with [autofocus] first, [tabindex] second and buttons/links/other natively-focusable elements last.
64
- * Upon closing the popout, focus will be returned to the popout's target.
65
- * If nothing within your popout's content is focusable, this prop will do nothing.
66
- */
67
- focusOnContent?: boolean;
68
- qa?: Record<string, string>;
69
- zIndex?: number;
70
- /**
71
- * Override react-popper per the API documentation here: https://github.com/FezVrasta/react-popper#api-documentation
72
- */
73
- popperProps?: Partial<PopperProps>;
74
- onClose?: () => void;
75
- onOpen?: () => void;
76
- /**
77
- * And optional callback to receive the scheduleUpdate function.
78
- * Use the function to recalculate the popout position in relation to the contents.
79
- */
80
- scheduleUpdateRef?: (arg0: () => void) => void;
81
- /**
82
- * Mount the popout at the bottom of the DOM (using React.Portal) instead of inside the current DOM tree
83
- */
84
- appendToBody?: boolean;
85
- /**
86
- * Override `FocusLock` props, see the API documentation for more details: https://github.com/theKashey/react-focus-lock#api
87
- */
88
- focusLockProps?: TypeFocusLockProps;
89
- }
90
- //# sourceMappingURL=PopoutTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PopoutTypes.d.ts","sourceRoot":"","sources":["../../../src/Popout/PopoutTypes.ts"],"names":[],"mappings":"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"}
@@ -1,5 +0,0 @@
1
- import Popout from "./Popout";
2
- export default Popout;
3
- export { Popout };
4
- export * from "./PopoutTypes";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Popout/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,eAAe,MAAM,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,cAAc,eAAe,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const TargetWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
2
- //# sourceMappingURL=styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Popout/styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,yGAIzB,CAAC"}
@@ -1,38 +0,0 @@
1
- var _excluded = ["isVisible", "children", "width", "direction"];
2
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
- import * as React from "react";
5
- import { useTransition } from "react-spring";
6
- import { MOTION_DURATION_MEDIUM } from "@sproutsocial/seeds-motion/dist/seeds-motion-unitless";
7
- export var SlideTransition = function SlideTransition(_ref) {
8
- var isVisible = _ref.isVisible,
9
- children = _ref.children,
10
- width = _ref.width,
11
- direction = _ref.direction,
12
- rest = _objectWithoutProperties(_ref, _excluded);
13
- var offset = width * (direction === "left" ? -1 : 1);
14
- var transitions = useTransition(isVisible, null, {
15
- from: {
16
- transform: "translateX(".concat(offset, "px)")
17
- },
18
- enter: {
19
- transform: "translateX(0)"
20
- },
21
- leave: {
22
- transform: "translateX(".concat(offset, "px)")
23
- },
24
- config: {
25
- duration: MOTION_DURATION_MEDIUM * 1000
26
- }
27
- });
28
- return /*#__PURE__*/React.createElement(React.Fragment, null, transitions.map(function (_ref2) {
29
- var key = _ref2.key,
30
- item = _ref2.item,
31
- props = _ref2.props;
32
- return children({
33
- key: key,
34
- isVisible: item,
35
- style: props
36
- });
37
- }));
38
- };
@@ -1,303 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["isOpen", "setIsOpen", "content", "children", "placement", "fullWidth", "zIndex", "focusOnContent", "onOpen", "onClose", "qa", "popperProps", "scheduleUpdateRef", "appendToBody", "focusLockProps", "color", "aria-haspopup", "disableWrapperAria", "id"],
3
- _excluded2 = ["autoFocus", "returnFocus"],
4
- _excluded3 = ["children"];
5
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
19
- import * as React from "react";
20
- import { useState, useEffect, useRef, useCallback, useMemo } from "react";
21
- import { useTransition, animated } from "react-spring";
22
- import FocusLock from "react-focus-lock";
23
- import { Popper } from "react-popper";
24
- import { MOTION_DURATION_FAST } from "@sproutsocial/seeds-motion/dist/seeds-motion-unitless";
25
- import { useMutationObserver } from "@sproutsocial/seeds-react-hooks";
26
- import Portal from "../Portal";
27
- import Box from "../Box";
28
- import { TargetWrapper } from "./styles";
29
- export var placements = {
30
- auto: "auto",
31
- top: "top",
32
- right: "right",
33
- bottom: "bottom",
34
- left: "left",
35
- "top-start": "top-start",
36
- "right-start": "right-start",
37
- "bottom-start": "bottom-start",
38
- "left-start": "left-start",
39
- "top-end": "top-end",
40
- "right-end": "right-end",
41
- "bottom-end": "bottom-end",
42
- "left-end": "left-end"
43
- };
44
- var doesRefContainEventTarget = function doesRefContainEventTarget(ref, event) {
45
- return ref.current && event.target instanceof Node && ref.current.contains(event.target);
46
- };
47
-
48
- // Transition definitions for fading in and out
49
- var transitionConfig = {
50
- from: {
51
- opacity: 0
52
- },
53
- enter: {
54
- opacity: 1
55
- },
56
- leave: {
57
- opacity: 0
58
- },
59
- config: {
60
- duration: MOTION_DURATION_FAST * 1000
61
- }
62
- };
63
- export function Popout(_ref) {
64
- var _popoutRef$current;
65
- var isOpen = _ref.isOpen,
66
- setIsOpen = _ref.setIsOpen,
67
- content = _ref.content,
68
- children = _ref.children,
69
- _ref$placement = _ref.placement,
70
- placement = _ref$placement === void 0 ? "auto" : _ref$placement,
71
- _ref$fullWidth = _ref.fullWidth,
72
- fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth,
73
- _ref$zIndex = _ref.zIndex,
74
- zIndex = _ref$zIndex === void 0 ? 7 : _ref$zIndex,
75
- _ref$focusOnContent = _ref.focusOnContent,
76
- focusOnContent = _ref$focusOnContent === void 0 ? true : _ref$focusOnContent,
77
- onOpen = _ref.onOpen,
78
- onClose = _ref.onClose,
79
- _ref$qa = _ref.qa,
80
- qa = _ref$qa === void 0 ? {} : _ref$qa,
81
- popperProps = _ref.popperProps,
82
- _ref$scheduleUpdateRe = _ref.scheduleUpdateRef,
83
- scheduleUpdateRef = _ref$scheduleUpdateRe === void 0 ? function () {} : _ref$scheduleUpdateRe,
84
- _ref$appendToBody = _ref.appendToBody,
85
- appendToBody = _ref$appendToBody === void 0 ? true : _ref$appendToBody,
86
- _ref$focusLockProps = _ref.focusLockProps,
87
- focusLockProps = _ref$focusLockProps === void 0 ? {} : _ref$focusLockProps,
88
- color = _ref.color,
89
- ariaHasPopup = _ref["aria-haspopup"],
90
- _ref$disableWrapperAr = _ref.disableWrapperAria,
91
- disableWrapperAria = _ref$disableWrapperAr === void 0 ? false : _ref$disableWrapperAr,
92
- id = _ref.id,
93
- rest = _objectWithoutProperties(_ref, _excluded);
94
- var PopoutComponentWrapper = appendToBody ? Portal : React.Fragment;
95
- var _useState = useState(false),
96
- _useState2 = _slicedToArray(_useState, 2),
97
- isInternalShown = _useState2[0],
98
- setIsInternalShown = _useState2[1];
99
- var isControlled = typeof isOpen === "boolean";
100
- var isShown = isControlled ? isOpen : isInternalShown;
101
- var setIsShown = useMemo(function () {
102
- return isControlled && setIsOpen ? setIsOpen : function (nextIsShown) {
103
- return setIsInternalShown(nextIsShown);
104
- };
105
- }, [isControlled, setIsOpen]);
106
- var targetRef = useRef();
107
- var popoutRef = useRef();
108
- var isFirstRender = useRef(true);
109
-
110
- // This callback will automatically trigger a recalculation of the popout position if the content is changed
111
- // eslint-disable-next-line @typescript-eslint/no-empty-function
112
- var scheduleUpdateCallback = useRef(function () {});
113
- useMutationObserver((_popoutRef$current = popoutRef.current) !== null && _popoutRef$current !== void 0 ? _popoutRef$current : null, {
114
- childList: true,
115
- characterData: true,
116
- subtree: true
117
- }, scheduleUpdateCallback.current);
118
- var _focusLockProps$autoF = focusLockProps.autoFocus,
119
- autoFocus = _focusLockProps$autoF === void 0 ? true : _focusLockProps$autoF,
120
- _focusLockProps$retur = focusLockProps.returnFocus,
121
- returnFocus = _focusLockProps$retur === void 0 ? true : _focusLockProps$retur,
122
- restFocusLockProps = _objectWithoutProperties(focusLockProps, _excluded2);
123
- var isInvalidContent = content === null || content === undefined;
124
-
125
- // Callbacks for showing, hiding, and toggling visibility of the popout
126
- // (Not used when isOpen is passed explicitly)
127
- var show = useCallback(function () {
128
- return setIsShown(true);
129
- }, [setIsShown]);
130
- var hide = useCallback(function () {
131
- return setIsShown(false);
132
- }, [setIsShown]);
133
- var toggle = useCallback(function () {
134
- return setIsShown(!isShown);
135
- }, [isShown, setIsShown]);
136
- useEffect(function () {
137
- var documentBody = document.body;
138
- if (isShown && documentBody) {
139
- // Callback passed to a click handler attached to document.body,
140
- // allowing user to close the popout by clicking outside
141
- var bodyClick = function bodyClick(e) {
142
- if (doesRefContainEventTarget(targetRef, e) || doesRefContainEventTarget(popoutRef, e)) {
143
- return;
144
- }
145
- setIsShown(false, e);
146
- };
147
-
148
- // Callback for allowing user to close by keying "esc"
149
- var onEsc = function onEsc(e) {
150
- // older browsers use "Esc"
151
- if (["Escape", "Esc"].includes(e.key)) {
152
- // stop propagation to avoid interacting with other components when popout is shown
153
- // ie if we have a popout shown in a modal and hit esc, we don't want to close both the popout and modal
154
- e.stopPropagation();
155
- setIsShown(false, e);
156
- }
157
- };
158
- documentBody.addEventListener("click", bodyClick, {
159
- capture: true
160
- });
161
- documentBody.addEventListener("keydown", onEsc, {
162
- capture: true
163
- });
164
- return function () {
165
- documentBody.removeEventListener("click", bodyClick, {
166
- capture: true
167
- });
168
- documentBody.removeEventListener("keydown", onEsc, {
169
- capture: true
170
- });
171
- };
172
- }
173
- }, [isShown, setIsShown]);
174
-
175
- // Manage onOpen and onClose callbacks
176
- useEffect(function () {
177
- // Don't fire onClose on the first render
178
- if (isFirstRender.current) {
179
- isFirstRender.current = false;
180
- return;
181
- }
182
- if (!onOpen && !onClose) {
183
- return;
184
- }
185
- if (isShown && onOpen) {
186
- onOpen();
187
- }
188
- if (!isShown && onClose) {
189
- onClose();
190
- }
191
- },
192
- // eslint-disable-next-line
193
- [isShown]);
194
- var transitions = useTransition(isShown, null, transitionConfig);
195
- // WAI-Aria properties for the popout trigger, disabled if necessary
196
- var ariaProps = useMemo(function () {
197
- return disableWrapperAria ? {} : {
198
- "aria-expanded": isShown,
199
- "aria-haspopup": ariaHasPopup ? ariaHasPopup : true
200
- };
201
- }, [isShown, ariaHasPopup, disableWrapperAria]);
202
-
203
- // In cases where a controlled popout is used (e.g. props.isOpen is true), we need
204
- // to wait for the targetRef to receive a value before rendering the popout. Otherwise,
205
- // the Popout component renders, but doesn't know how to position itself due the
206
- // `refereElement` property being undefined.
207
- var _useState3 = useState(
208
- // Only trigger this shouldRenderPopout logic when using a controlled component.
209
- // The reason for that is because controlled components may render the popout
210
- // immediately before the targetRef has a value set to it.
211
- !isControlled),
212
- _useState4 = _slicedToArray(_useState3, 2),
213
- shouldRenderPopout = _useState4[0],
214
- setShouldRenderPopout = _useState4[1];
215
- var childrenRef = function childrenRef(el) {
216
- targetRef.current = el;
217
- if (targetRef.current) {
218
- setShouldRenderPopout(true);
219
- }
220
- };
221
- return /*#__PURE__*/React.createElement(React.Fragment, null, typeof children === "function" ? children({
222
- ref: childrenRef,
223
- toggle: toggle,
224
- show: show,
225
- hide: hide,
226
- ariaProps: ariaProps
227
- }) : /*#__PURE__*/React.createElement(TargetWrapper, _extends({}, qa, {
228
- id: id
229
- }, rest, {
230
- ref: childrenRef
231
- }), /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, ariaProps), !isControlled ? {
232
- onClick: toggle
233
- } : undefined))), shouldRenderPopout && !isInvalidContent && transitions.map(function (_ref2) {
234
- var item = _ref2.item,
235
- key = _ref2.key,
236
- props = _ref2.props;
237
- return item && /*#__PURE__*/React.createElement(PopoutComponentWrapper, {
238
- key: key
239
- }, /*#__PURE__*/React.createElement(Popper, _extends({
240
- referenceElement: targetRef.current,
241
- placement: placement,
242
- modifiers: {
243
- preventOverflow: {
244
- boundariesElement: "viewport"
245
- }
246
- }
247
- }, popperProps), function (_ref3) {
248
- var ref = _ref3.ref,
249
- style = _ref3.style,
250
- placement = _ref3.placement,
251
- outOfBoundaries = _ref3.outOfBoundaries,
252
- scheduleUpdate = _ref3.scheduleUpdate;
253
- var interceptRef = function interceptRef(el) {
254
- popoutRef.current = el;
255
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
256
- // @ts-ignore
257
- ref(el);
258
- };
259
- scheduleUpdateCallback.current = scheduleUpdate;
260
- scheduleUpdateRef(scheduleUpdate);
261
- return /*#__PURE__*/React.createElement("div", _extends({
262
- ref: interceptRef,
263
- style: _objectSpread(_objectSpread({}, style), {}, {
264
- zIndex: zIndex,
265
- width: fullWidth && targetRef.current ? targetRef.current.offsetWidth : "initial"
266
- }),
267
- "data-placement": placement,
268
- "data-qa-popout": "",
269
- "data-qa-popout-isopen": isOpen === true
270
- // TODO: fix this type since `color` should be valid here. TS can't resolve the correct type.
271
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
272
- // @ts-ignore
273
- ,
274
- color: color
275
- }, rest), item && !outOfBoundaries && /*#__PURE__*/React.createElement(animated.div, {
276
- style: props
277
- }, /*#__PURE__*/React.createElement(FocusLock, _extends({
278
- autoFocus: autoFocus,
279
- returnFocus: returnFocus,
280
- disabled: !focusOnContent
281
- }, restFocusLockProps), typeof content === "function" && content({
282
- hide: hide
283
- }), typeof content !== "function" && content)));
284
- }));
285
- }));
286
- }
287
- var PopoutContent = function PopoutContent(_ref4) {
288
- var children = _ref4.children,
289
- rest = _objectWithoutProperties(_ref4, _excluded3);
290
- return /*#__PURE__*/React.createElement(Box, _extends({
291
- bg: "container.background.base",
292
- color: "text.body",
293
- border: 500,
294
- borderColor: "container.border.base",
295
- borderRadius: "outer",
296
- boxShadow: "medium",
297
- p: 400,
298
- m: 300
299
- }, rest), children);
300
- };
301
- PopoutContent.displayName = "Popout.Content";
302
- Popout.Content = PopoutContent;
303
- export default Popout;
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import Popout from "./Popout";
2
- export default Popout;
3
- export { Popout };
4
- export * from "./PopoutTypes";
@@ -1,6 +0,0 @@
1
- import styled from "styled-components";
2
- import { COMMON, LAYOUT } from "@sproutsocial/seeds-react-system-props";
3
- export var TargetWrapper = styled.div.withConfig({
4
- displayName: "styles__TargetWrapper",
5
- componentId: "sc-pftzv7-0"
6
- })(["display:inline-block;", " ", ""], COMMON, LAYOUT);