@sproutsocial/racine 20.8.0 → 20.9.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 20.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2e135c53a: Add prop to Drawer to allow certain elements to be exempt from the Drawer focus lock
8
+
9
+ This is helpful when Pendo Guide are activated while a drawer is open.
10
+
11
+ - 60ba119e2: The width of Drawer can now be customized using the `width` prop.
12
+
3
13
  ## 20.8.0
4
14
 
5
15
  ### Minor Changes
@@ -35,6 +35,7 @@ export type TypeDrawerProps = {
35
35
  onClose: () => void,
36
36
  zIndex?: number,
37
37
  closeTargets?: Array<Element>,
38
+ width?: number,
38
39
  ...
39
40
  };
40
41
  declare class DrawerContainer extends React.Component<TypeDrawerProps> {
@@ -17,8 +17,8 @@ var _SlideTransition = require("./SlideTransition");
17
17
  var _styles = _interopRequireWildcard(require("./styles"));
18
18
  var _excluded = ["title", "id", "children", "render"],
19
19
  _excluded2 = ["children"],
20
- _excluded3 = ["id", "style", "offset", "direction", "children", "disableCloseOnClickOutside", "onClose", "zIndex", "closeTargets"],
21
- _excluded4 = ["children", "closeButtonLabel", "direction", "disableCloseOnClickOutside", "id", "isOpen", "offset", "onClose", "zIndex", "closeTargets"];
20
+ _excluded3 = ["id", "style", "offset", "direction", "children", "disableCloseOnClickOutside", "onClose", "zIndex", "closeTargets", "width", "focusLockExemptCheck"],
21
+ _excluded4 = ["children", "closeButtonLabel", "direction", "disableCloseOnClickOutside", "id", "isOpen", "offset", "onClose", "zIndex", "closeTargets", "width"];
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -30,8 +30,6 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
30
30
  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; }
31
31
  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; }
32
32
  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); } // eslint-disable-next-line import/no-deprecated
33
- // If ever we needed to make drawer width configurable, move this to a default prop
34
- var DRAWER_WIDTH = 600;
35
33
  var AnimatedDrawer = (0, _reactSpring.animated)(_styles.default);
36
34
  var doesRefContainEventTarget = function doesRefContainEventTarget(ref, event) {
37
35
  return ref.current && event.target instanceof Node && ref.current.contains(event.target);
@@ -103,6 +101,8 @@ var Drawer = function Drawer(_ref3) {
103
101
  onClose = _ref3.onClose,
104
102
  zIndex = _ref3.zIndex,
105
103
  closeTargets = _ref3.closeTargets,
104
+ width = _ref3.width,
105
+ focusLockExemptCheck = _ref3.focusLockExemptCheck,
106
106
  rest = _objectWithoutProperties(_ref3, _excluded3);
107
107
  var drawerRef = (0, React.useRef)(null);
108
108
  (0, React.useEffect)(function () {
@@ -141,11 +141,14 @@ var Drawer = function Drawer(_ref3) {
141
141
  return /*#__PURE__*/React.createElement(_reactFocusLock.default, {
142
142
  key: id,
143
143
  autoFocus: true,
144
- returnFocus: true
144
+ returnFocus: true,
145
+ whiteList: focusLockExemptCheck ? function (e) {
146
+ return !focusLockExemptCheck(e);
147
+ } : undefined
145
148
  }, /*#__PURE__*/React.createElement(AnimatedDrawer, _extends({
146
149
  ref: drawerRef,
147
150
  style: style,
148
- width: DRAWER_WIDTH,
151
+ width: width,
149
152
  offset: offset,
150
153
  direction: direction,
151
154
  "data-qa-drawer": id,
@@ -168,6 +171,8 @@ var DrawerContainer = function DrawerContainer(_ref4) {
168
171
  zIndex = _ref4$zIndex === void 0 ? 7 : _ref4$zIndex,
169
172
  _ref4$closeTargets = _ref4.closeTargets,
170
173
  closeTargets = _ref4$closeTargets === void 0 ? [] : _ref4$closeTargets,
174
+ _ref4$width = _ref4.width,
175
+ width = _ref4$width === void 0 ? 600 : _ref4$width,
171
176
  rest = _objectWithoutProperties(_ref4, _excluded4);
172
177
  return /*#__PURE__*/React.createElement(_Portal.default, {
173
178
  id: id
@@ -177,7 +182,7 @@ var DrawerContainer = function DrawerContainer(_ref4) {
177
182
  closeButtonLabel: closeButtonLabel
178
183
  }
179
184
  }, /*#__PURE__*/React.createElement(_SlideTransition.SlideTransition, {
180
- width: DRAWER_WIDTH + offset,
185
+ width: width + offset,
181
186
  direction: direction,
182
187
  isVisible: isOpen
183
188
  }, function (_ref5) {
@@ -196,6 +201,7 @@ var DrawerContainer = function DrawerContainer(_ref4) {
196
201
  onClose: onClose,
197
202
  zIndex: zIndex,
198
203
  closeTargets: closeTargets,
204
+ width: width,
199
205
  "data-qa-drawer": id || '',
200
206
  "data-qa-drawer-isopen": isOpen === true
201
207
  }, rest), children);
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { TypeDrawerCloseButtonProps, TypeDrawerHeaderProps, TypeDrawerProps, TypeDrawerContentProps } from './DrawerTypes';
3
3
  declare const DrawerContainer: {
4
- ({ children, closeButtonLabel, direction, disableCloseOnClickOutside, id, isOpen, offset, onClose, zIndex, closeTargets, ...rest }: TypeDrawerProps): JSX.Element;
4
+ ({ children, closeButtonLabel, direction, disableCloseOnClickOutside, id, isOpen, offset, onClose, zIndex, closeTargets, width, ...rest }: TypeDrawerProps): JSX.Element;
5
5
  Header: {
6
6
  ({ title, id, children, render, ...rest }: TypeDrawerHeaderProps): React.ReactElement<any, any> | null;
7
7
  displayName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/Drawer/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAEV,0BAA0B,EAC1B,qBAAqB,EACrB,eAAe,EAEf,sBAAsB,EACvB,MAAM,eAAe,CAAC;AA+KvB,QAAA,MAAM,eAAe;wIAYlB,eAAe;;mDA7If,qBAAqB;;;;gCAmCoB,sBAAsB;;;;gBAjEhC,0BAA0B;;;CAiN3D,CAAC;AAUF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/Drawer/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAEV,0BAA0B,EAC1B,qBAAqB,EACrB,eAAe,EAEf,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAsLvB,QAAA,MAAM,eAAe;+IAalB,eAAe;;mDAvJf,qBAAqB;;;;gCAmCoB,sBAAsB;;;;gBAjEhC,0BAA0B;;;CA4N3D,CAAC;AAUF,eAAe,eAAe,CAAC"}
@@ -37,6 +37,8 @@ export interface TypeDrawerProps extends TypeStyledComponentsCommonProps, TypeSy
37
37
  onClose: () => void;
38
38
  zIndex?: number;
39
39
  closeTargets?: Array<Element>;
40
+ width?: number;
41
+ focusLockExemptCheck?: (element: HTMLElement) => boolean;
40
42
  }
41
43
  export interface TypeDrawerContentProps extends TypeBoxProps {
42
44
  children?: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerTypes.d.ts","sourceRoot":"","sources":["../../../src/Drawer/DrawerTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,+BAA+B,EAAC,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AACtC,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAEhC,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC;IAEpB,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,0BACf,SAAQ,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC;IACzC,0IAA0I;IAC1I,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,KAAK,CAAC,EAA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AAC;IAChB,YAAY,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC;CAC1D;AAED,MAAM,WAAW,sBAAuB,SAAQ,YAAY;IAC1D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
@@ -1,8 +1,8 @@
1
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
2
  var _excluded = ["title", "id", "children", "render"],
3
3
  _excluded2 = ["children"],
4
- _excluded3 = ["id", "style", "offset", "direction", "children", "disableCloseOnClickOutside", "onClose", "zIndex", "closeTargets"],
5
- _excluded4 = ["children", "closeButtonLabel", "direction", "disableCloseOnClickOutside", "id", "isOpen", "offset", "onClose", "zIndex", "closeTargets"];
4
+ _excluded3 = ["id", "style", "offset", "direction", "children", "disableCloseOnClickOutside", "onClose", "zIndex", "closeTargets", "width", "focusLockExemptCheck"],
5
+ _excluded4 = ["children", "closeButtonLabel", "direction", "disableCloseOnClickOutside", "id", "isOpen", "offset", "onClose", "zIndex", "closeTargets", "width"];
6
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
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
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; }
@@ -23,8 +23,6 @@ import Text from "../Text";
23
23
  import Portal from "../Portal";
24
24
  import { SlideTransition } from "./SlideTransition";
25
25
  import Container, { Content } from "./styles";
26
- // If ever we needed to make drawer width configurable, move this to a default prop
27
- var DRAWER_WIDTH = 600;
28
26
  var AnimatedDrawer = animated(Container);
29
27
  var doesRefContainEventTarget = function doesRefContainEventTarget(ref, event) {
30
28
  return ref.current && event.target instanceof Node && ref.current.contains(event.target);
@@ -96,6 +94,8 @@ var Drawer = function Drawer(_ref3) {
96
94
  onClose = _ref3.onClose,
97
95
  zIndex = _ref3.zIndex,
98
96
  closeTargets = _ref3.closeTargets,
97
+ width = _ref3.width,
98
+ focusLockExemptCheck = _ref3.focusLockExemptCheck,
99
99
  rest = _objectWithoutProperties(_ref3, _excluded3);
100
100
  var drawerRef = useRef(null);
101
101
  useEffect(function () {
@@ -134,11 +134,14 @@ var Drawer = function Drawer(_ref3) {
134
134
  return /*#__PURE__*/React.createElement(FocusLock, {
135
135
  key: id,
136
136
  autoFocus: true,
137
- returnFocus: true
137
+ returnFocus: true,
138
+ whiteList: focusLockExemptCheck ? function (e) {
139
+ return !focusLockExemptCheck(e);
140
+ } : undefined
138
141
  }, /*#__PURE__*/React.createElement(AnimatedDrawer, _extends({
139
142
  ref: drawerRef,
140
143
  style: style,
141
- width: DRAWER_WIDTH,
144
+ width: width,
142
145
  offset: offset,
143
146
  direction: direction,
144
147
  "data-qa-drawer": id,
@@ -161,6 +164,8 @@ var DrawerContainer = function DrawerContainer(_ref4) {
161
164
  zIndex = _ref4$zIndex === void 0 ? 7 : _ref4$zIndex,
162
165
  _ref4$closeTargets = _ref4.closeTargets,
163
166
  closeTargets = _ref4$closeTargets === void 0 ? [] : _ref4$closeTargets,
167
+ _ref4$width = _ref4.width,
168
+ width = _ref4$width === void 0 ? 600 : _ref4$width,
164
169
  rest = _objectWithoutProperties(_ref4, _excluded4);
165
170
  return /*#__PURE__*/React.createElement(Portal, {
166
171
  id: id
@@ -170,7 +175,7 @@ var DrawerContainer = function DrawerContainer(_ref4) {
170
175
  closeButtonLabel: closeButtonLabel
171
176
  }
172
177
  }, /*#__PURE__*/React.createElement(SlideTransition, {
173
- width: DRAWER_WIDTH + offset,
178
+ width: width + offset,
174
179
  direction: direction,
175
180
  isVisible: isOpen
176
181
  }, function (_ref5) {
@@ -189,6 +194,7 @@ var DrawerContainer = function DrawerContainer(_ref4) {
189
194
  onClose: onClose,
190
195
  zIndex: zIndex,
191
196
  closeTargets: closeTargets,
197
+ width: width,
192
198
  "data-qa-drawer": id || '',
193
199
  "data-qa-drawer-isopen": isOpen === true
194
200
  }, rest), children);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/racine",
3
- "version": "20.8.0",
3
+ "version": "20.9.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "__flow__",