@homebound/beam 2.276.0 → 2.277.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.
@@ -14,14 +14,22 @@ function ScrollShadows(props) {
14
14
  if (!bgColor.includes("rgba")) {
15
15
  throw new Error("ScrollShadows: bgColor prop must be in the format 'rgba(255, 255, 255, 1)'");
16
16
  }
17
- const transparentBgColor = bgColor.replace(/,1\)$/, ",0)");
18
- const startShadowStyles = !horizontal ? src_1.Css.top0.left0.right0.hPx(40).$ : src_1.Css.left0.top0.bottom0.wPx(25).$;
19
- const endShadowStyles = !horizontal ? src_1.Css.bottom0.left0.right0.hPx(40).$ : src_1.Css.right0.top0.bottom0.wPx(25).$;
20
- const startGradientDeg = !horizontal ? 180 : 90;
21
- const endGradientDeg = !horizontal ? 0 : 270;
22
17
  const [showStartShadow, setShowStartShadow] = (0, react_1.useState)(false);
23
18
  const [showEndShadow, setShowEndShadow] = (0, react_1.useState)(false);
24
19
  const scrollRef = (0, react_1.useRef)(null);
20
+ // The shadow styles will rarely every change. Memoize them to avoid recomputing them when we don't have to.
21
+ const [startShadowStyles, endShadowStyles] = (0, react_1.useMemo)(() => {
22
+ const transparentBgColor = bgColor.replace(/,1\)$/, ",0)");
23
+ const commonStyles = src_1.Css.absolute.z3.$;
24
+ const startShadowStyles = !horizontal ? src_1.Css.top0.left0.right0.hPx(40).$ : src_1.Css.left0.top0.bottom0.wPx(25).$;
25
+ const endShadowStyles = !horizontal ? src_1.Css.bottom0.left0.right0.hPx(40).$ : src_1.Css.right0.top0.bottom0.wPx(25).$;
26
+ const startGradient = `linear-gradient(${!horizontal ? 180 : 90}deg, ${bgColor} 0%, ${transparentBgColor} 92%);`;
27
+ const endGradient = `linear-gradient(${!horizontal ? 0 : 270}deg, ${bgColor} 0%, ${transparentBgColor} 92%);`;
28
+ return [
29
+ { ...commonStyles, ...startShadowStyles, ...src_1.Css.add("background", startGradient).$ },
30
+ { ...commonStyles, ...endShadowStyles, ...src_1.Css.add("background", endGradient).$ },
31
+ ];
32
+ }, [horizontal, bgColor]);
25
33
  const updateScrollProps = (0, react_1.useCallback)((el) => {
26
34
  const { scrollTop, scrollHeight, clientHeight, scrollWidth, scrollLeft, clientWidth } = el;
27
35
  const start = horizontal ? scrollLeft : scrollTop;
@@ -37,13 +45,7 @@ function ScrollShadows(props) {
37
45
  return ((0, jsx_runtime_1.jsxs)("div", { css: src_1.Css.relative.overflowHidden
38
46
  .h(height)
39
47
  .w(width)
40
- .df.fd(!horizontal ? "column" : "row").$, ...tid, children: [showStartShadow && ((0, jsx_runtime_1.jsx)("div", { css: {
41
- ...startShadowStyles,
42
- ...src_1.Css.absolute.add("background", `linear-gradient(${startGradientDeg}deg, ${bgColor} 0%, ${transparentBgColor} 92%);`).$,
43
- } })), showEndShadow && ((0, jsx_runtime_1.jsx)("div", { css: {
44
- ...endShadowStyles,
45
- ...src_1.Css.absolute.add("background", `linear-gradient(${endGradientDeg}deg, ${bgColor} 0%, ${transparentBgColor} 92%)`).$,
46
- } })), (0, jsx_runtime_1.jsx)("div", { css: {
48
+ .df.fd(!horizontal ? "column" : "row").$, ...tid, children: [showStartShadow && (0, jsx_runtime_1.jsx)("div", { css: startShadowStyles }), showEndShadow && (0, jsx_runtime_1.jsx)("div", { css: endShadowStyles }), (0, jsx_runtime_1.jsx)("div", { css: {
47
49
  ...xss,
48
50
  ...src_1.Css.overflowAuto.fg1.addIn("&::-webkit-scrollbar", { display: "none" }).add("scrollbarWidth", "none").$,
49
51
  }, onScroll: (e) => updateScrollProps(e.currentTarget), ref: scrollRef, children: children })] }));
@@ -5,13 +5,13 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const react_aria_1 = require("react-aria");
7
7
  const react_router_1 = require("react-router");
8
- const react_router_dom_1 = require("react-router-dom");
9
8
  const Avatar_1 = require("../Avatar");
10
9
  const Icon_1 = require("../Icon");
11
10
  const Tooltip_1 = require("../Tooltip");
12
11
  const Css_1 = require("../../Css");
13
12
  const utils_1 = require("../../utils");
14
13
  const defaultTestId_1 = require("../../utils/defaultTestId");
14
+ const react_router_dom_1 = require("react-router-dom");
15
15
  function MenuItemImpl(props) {
16
16
  const { item, state, onClose, contrast } = props;
17
17
  const menuItem = item.value;
@@ -85,7 +85,7 @@ function maybeWrapInLink(onClick, content, disabled) {
85
85
  if (disabled || typeof onClick !== "string") {
86
86
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: content });
87
87
  }
88
- return (0, utils_1.isAbsoluteUrl)(onClick) ? ((0, jsx_runtime_1.jsxs)("a", { href: onClick, target: "_blank", rel: "noopener noreferrer", className: "navLink", css: Css_1.Css.df.aic.jcsb.w100.$, children: [content, (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.ml2.$, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "linkExternal" }) })] })) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.NavLink, { to: onClick, className: "navLink", children: content }));
88
+ return (0, utils_1.isAbsoluteUrl)(onClick) ? ((0, jsx_runtime_1.jsxs)("a", { href: onClick, target: "_blank", rel: "noopener noreferrer", className: "navLink", css: Css_1.Css.df.aic.jcsb.w100.$, children: [content, (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.ml2.$, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "linkExternal" }) })] })) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, { className: "navLink", to: onClick, children: content }));
89
89
  }
90
90
  function isIconMenuItem(item) {
91
91
  return item && typeof item === "object" && "icon" in item;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.276.0",
3
+ "version": "2.277.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",