@sproutsocial/racine 8.3.0 → 8.4.0-collapsible-updates.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.
@@ -5,9 +5,7 @@ exports.default = exports.Avatar = void 0;
5
5
 
6
6
  var React = _interopRequireWildcard(require("react"));
7
7
 
8
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
-
10
- var _classnames = _interopRequireDefault(require("classnames"));
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
9
 
12
10
  var _Box = _interopRequireDefault(require("../Box"));
13
11
 
@@ -33,20 +31,8 @@ var AvatarText = (0, _styledComponents.default)(function (_ref) {
33
31
  }).withConfig({
34
32
  displayName: "Avatar__AvatarText",
35
33
  componentId: "yx873f-0"
36
- })(["font-size:", "px;color:", "px;"], function (props) {
34
+ })(["font-size:", "px;"], function (props) {
37
35
  return props.fontSize;
38
- }, function (props) {
39
- return props.color;
40
- });
41
- var Container = (0, _styledComponents.default)(_Box.default).withConfig({
42
- displayName: "Avatar__Container",
43
- componentId: "yx873f-1"
44
- })(["", ""], function (_ref2) {
45
- var theme = _ref2.theme,
46
- type = _ref2.type,
47
- variant = _ref2.variant,
48
- bg = _ref2.bg;
49
- return (0, _styledComponents.css)(["color:", ";background:", ";"], theme.colors[type][variant === "dark" ? "200" : "900"], bg ? bg : theme.colors[type][variant === "dark" ? "900" : "200"]);
50
36
  });
51
37
 
52
38
  var getInitials = function getInitials(name, fallback) {
@@ -62,20 +48,14 @@ var getInitials = function getInitials(name, fallback) {
62
48
  .join("");
63
49
  };
64
50
 
65
- var Avatar = function Avatar(_ref3) {
66
- var _ref3$appearance = _ref3.appearance,
67
- appearance = _ref3$appearance === void 0 ? "circle" : _ref3$appearance,
68
- name = _ref3.name,
69
- src = _ref3.src,
70
- _ref3$variant = _ref3.variant,
71
- variant = _ref3$variant === void 0 ? "light" : _ref3$variant,
72
- _ref3$type = _ref3.type,
73
- type = _ref3$type === void 0 ? "neutral" : _ref3$type,
74
- _ref3$size = _ref3.size,
75
- size = _ref3$size === void 0 ? "40px" : _ref3$size,
76
- bg = _ref3.bg,
77
- color = _ref3.color,
78
- rest = _objectWithoutPropertiesLoose(_ref3, ["appearance", "name", "src", "variant", "type", "size", "bg", "color"]);
51
+ var Avatar = function Avatar(_ref2) {
52
+ var _ref2$appearance = _ref2.appearance,
53
+ appearance = _ref2$appearance === void 0 ? "circle" : _ref2$appearance,
54
+ name = _ref2.name,
55
+ src = _ref2.src,
56
+ _ref2$size = _ref2.size,
57
+ size = _ref2$size === void 0 ? "40px" : _ref2$size,
58
+ rest = _objectWithoutPropertiesLoose(_ref2, ["appearance", "name", "src", "size"]);
79
59
 
80
60
  var _useState = (0, React.useState)(false),
81
61
  imageFailedLoading = _useState[0],
@@ -89,8 +69,7 @@ var Avatar = function Avatar(_ref3) {
89
69
  }, [setImageFailedLoading]); // Font size for initials is half the size of the avatar, rounded down.
90
70
 
91
71
  var fontSize = Math.floor(Number(size.replace("px", "")) * 0.4);
92
- return /*#__PURE__*/React.createElement(Container, _extends({
93
- className: (0, _classnames.default)(variant),
72
+ return /*#__PURE__*/React.createElement(_Box.default, _extends({
94
73
  size: size,
95
74
  overflow: "hidden",
96
75
  borderRadius: appearance === "leaf" ? "40% 0 40% 0" : "50%",
@@ -100,16 +79,13 @@ var Avatar = function Avatar(_ref3) {
100
79
  justifyContent: "center",
101
80
  alignItems: "center",
102
81
  title: name,
103
- bg: bg,
104
- variant: variant,
105
- type: type,
82
+ bg: "neutral.200",
106
83
  "data-qa-user-avatar": name // $FlowIssue - upgrade v0.112.0
107
84
 
108
85
  }, rest), !src || imageFailedLoading ? /*#__PURE__*/React.createElement(AvatarText, {
109
86
  lineHeight: size,
110
87
  fontWeight: "semibold",
111
- fontSize: fontSize,
112
- color: color
88
+ fontSize: fontSize
113
89
  }, initials) : /*#__PURE__*/React.createElement(_Image.default, {
114
90
  alt: name,
115
91
  width: "auto",
@@ -29,7 +29,10 @@ var Collapsible = function Collapsible(_ref) {
29
29
  _ref$isOpen = _ref.isOpen,
30
30
  isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
31
31
  _ref$offset = _ref.offset,
32
- offset = _ref$offset === void 0 ? 0 : _ref$offset;
32
+ offset = _ref$offset === void 0 ? 0 : _ref$offset,
33
+ _ref$collapsedHeight = _ref.collapsedHeight,
34
+ collapsedHeight = _ref$collapsedHeight === void 0 ? 0 : _ref$collapsedHeight,
35
+ openHeight = _ref.openHeight;
33
36
 
34
37
  var _useState = (0, React.useState)("Racine-collapsible-" + idCounter++),
35
38
  id = _useState[0];
@@ -38,11 +41,25 @@ var Collapsible = function Collapsible(_ref) {
38
41
  value: {
39
42
  isOpen: isOpen,
40
43
  id: id,
41
- offset: offset
44
+ offset: offset,
45
+ collapsedHeight: collapsedHeight,
46
+ openHeight: openHeight
42
47
  }
43
48
  }, children);
44
49
  };
45
50
 
51
+ var determineMaxHeight = function determineMaxHeight(isHidden, openHeight, computedHeight) {
52
+ // If isHidden is undefined this is the first render. Return undefined so the max-height prop is not added
53
+ // This is a hack to prevent css from animating if it begins in the open state
54
+ // css animates when attribute values change (IE from 0 to another number)
55
+ // css does not animate when simply adding an attribute to an HTML element
56
+ if (isHidden === undefined) return undefined; // If the user has defined an explicit open height, return that as the max height
57
+
58
+ if (!!openHeight) return openHeight; // Otherwise, fallback to the computed height
59
+
60
+ return computedHeight;
61
+ };
62
+
46
63
  var Trigger = function Trigger(_ref2) {
47
64
  var children = _ref2.children,
48
65
  rest = _objectWithoutPropertiesLoose(_ref2, ["children"]);
@@ -64,20 +81,18 @@ var Panel = function Panel(_ref3) {
64
81
  var _useContext2 = (0, React.useContext)(CollapsibleContext),
65
82
  isOpen = _useContext2.isOpen,
66
83
  id = _useContext2.id,
67
- offset = _useContext2.offset;
84
+ offset = _useContext2.offset,
85
+ collapsedHeight = _useContext2.collapsedHeight,
86
+ openHeight = _useContext2.openHeight;
68
87
 
69
88
  var ref = (0, React.useRef)();
70
89
  var measurement = (0, _useMeasure.default)(ref);
71
90
 
72
91
  var _useState2 = (0, React.useState)(undefined),
73
92
  isHidden = _useState2[0],
74
- setIsHidden = _useState2[1]; // If this is the initial render isHidden will be undefined
75
- // When that is the case, set maxHeight to undefined rather than the comptued 0
76
- // This prevents an initial expansion animation if a component starts out open
77
- // There is no animation because css is not changing the maxHeight property after mount
78
-
93
+ setIsHidden = _useState2[1];
79
94
 
80
- var maxHeight = isHidden === undefined ? undefined : measurement.height + offset;
95
+ var maxHeight = determineMaxHeight(isHidden, openHeight, measurement.height + offset);
81
96
  /* We use the "hidden" attribute to remove the contents of the panel from the tab order of the page, but it fucks with the animation. This logic sets a slight timeout on setting the prop so that the animation has time to complete before the attribute is set. */
82
97
 
83
98
  (0, React.useEffect)(function () {
@@ -103,12 +118,14 @@ var Panel = function Panel(_ref3) {
103
118
  }
104
119
  }, [isOpen]);
105
120
  return /*#__PURE__*/React.createElement(_styles.CollapsingBox, _extends({
106
- maxHeight: isOpen ? maxHeight : "0",
121
+ scrollable: isOpen,
122
+ maxHeight: isOpen ? maxHeight : collapsedHeight,
123
+ minHeight: collapsedHeight,
107
124
  "data-qa-collapsible": "",
108
125
  "data-qa-collapsible-isopen": isOpen === true
109
126
  }, rest), /*#__PURE__*/React.createElement(_Box.default, {
110
127
  width: "100%",
111
- hidden: isHidden,
128
+ hidden: isHidden && collapsedHeight === 0,
112
129
  "aria-hidden": !isOpen,
113
130
  id: id,
114
131
  ref: ref
@@ -12,9 +12,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
  var CollapsingBox = (0, _styledComponents.default)(_Box.default).withConfig({
13
13
  displayName: "styles__CollapsingBox",
14
14
  componentId: "sc-1xvfbl7-0"
15
- })(["transition:max-height ", " ", ";will-change:max-height;overflow:hidden;"], function (p) {
15
+ })(["transition:max-height ", " ", ";will-change:max-height;position:relative;overflow:auto;background:linear-gradient( ", " 30%,rgba(255,255,255,0) ),linear-gradient( rgba(255,255,255,0),", " 70% ) 0 100%,radial-gradient( farthest-side at 50% 0,rgb(39 51 51 / 5%),rgba(0,0,0,0) ),radial-gradient( farthest-side at 50% 100%,rgb(39 51 51 / 5%),rgba(0,0,0,0) ) 0 100%;background-repeat:no-repeat;background-size:100% 40px,100% 40px,100% 14px,100% 14px;background-attachment:local,local,scroll,scroll;", ";"], function (p) {
16
16
  return p.theme.duration.medium;
17
17
  }, function (p) {
18
18
  return p.theme.easing.ease_inout;
19
+ }, function (p) {
20
+ return p.theme.colors.neutral[100];
21
+ }, function (p) {
22
+ return p.theme.colors.neutral[100];
23
+ }, function (_ref) {
24
+ var scrollable = _ref.scrollable;
25
+ return scrollable ? "overflow: auto" : "overflow: hidden";
19
26
  });
20
27
  exports.CollapsingBox = CollapsingBox;
@@ -34,7 +34,6 @@ module.exports = {
34
34
  "barcode": "0 0 18 16",
35
35
  "basketball": "0 0 16 16",
36
36
  "bell-outline": "0 0 14 16",
37
- "bigcommerce": "0 0 16 16",
38
37
  "bitly": "0 0 16 16",
39
38
  "bold": "0 0 16 16",
40
39
  "book": "0 0 14 16",
@@ -340,7 +339,6 @@ module.exports = {
340
339
  "window-minimize": "0 0 16 16",
341
340
  "window-regular": "0 0 16 16",
342
341
  "window-restore": "0 0 16 16",
343
- "woocommerce": "0 0 16 16",
344
342
  "x": "0 0 16 18",
345
343
  "yelp-full-star": "0 0 16 16",
346
344
  "yelp-half-star": "0 0 16 16",
@@ -20,7 +20,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
20
20
  var Container = (0, _styledComponents.default)(_Text.default).withConfig({
21
21
  displayName: "styles__Container",
22
22
  componentId: "adcw4a-0"
23
- })(["border:0;font-family:", ";text-decoration:", ";appearance:none;cursor:pointer;", " font-weight:", ";color:", ";&:hover{color:", ";text-decoration:underline;}&:active{color:", ";}&:focus{", "}&:focus:active{box-shadow:none;}", " ", " ", " ", " ", ""], function (props) {
23
+ })(["border:0;font-family:", ";text-decoration:", ";appearance:none;cursor:pointer;", " font-weight:", ";color:", ";&:hover{color:", ";text-decoration:underline;}&:active{color:", ";}&:focus{", "}&:focus:active{box-shadow:none;}", " ", " ", " ", ""], function (props) {
24
24
  return props.theme.fontFamily;
25
25
  }, function (props) {
26
26
  return props.underline ? "underline" : "none";
@@ -38,6 +38,6 @@ var Container = (0, _styledComponents.default)(_Text.default).withConfig({
38
38
  return !props.href && (0, _styledComponents.css)(["background:none;"]);
39
39
  }, function (props) {
40
40
  return props.disabled && _mixins.disabled;
41
- }, _systemProps.COMMON, _systemProps.TYPOGRAPHY, _systemProps.FLEXBOX);
41
+ }, _systemProps.COMMON, _systemProps.TYPOGRAPHY);
42
42
  var _default = Container;
43
43
  exports.default = _default;
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactVirtualized = require("react-virtualized");
11
11
 
12
+ var _AutoSizer = _interopRequireDefault(require("react-virtualized/dist/es/AutoSizer"));
13
+
12
14
  var _Box = _interopRequireDefault(require("../Box"));
13
15
 
14
16
  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); }
@@ -57,7 +59,7 @@ var VirtualizedList = function VirtualizedList(_ref) {
57
59
  })));
58
60
  });
59
61
  }, [items, getItemProps, cache, itemWrapperProps]);
60
- return /*#__PURE__*/_react.default.createElement(_reactVirtualized.AutoSizer, null, function (_ref4) {
62
+ return /*#__PURE__*/_react.default.createElement(_AutoSizer.default, null, function (_ref4) {
61
63
  var height = _ref4.height,
62
64
  width = _ref4.width;
63
65
  return /*#__PURE__*/_react.default.createElement(_styles.default, _extends({