@homebound/beam 2.182.0 → 2.183.1

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,10 +5,12 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const utils_1 = require("@react-aria/utils");
6
6
  const react_1 = require("react");
7
7
  const react_aria_1 = require("react-aria");
8
- const index_1 = require("../index");
8
+ const Icon_1 = require("./Icon");
9
+ const Css_1 = require("../Css");
10
+ const utils_2 = require("../utils");
9
11
  function Accordion(props) {
10
12
  const { title, children, size, disabled = false, defaultExpanded = false, topBorder = true, bottomBorder = false, index, setExpandedIndex, } = props;
11
- const testIds = (0, index_1.useTestIds)(props, "accordion");
13
+ const testIds = (0, utils_2.useTestIds)(props, "accordion");
12
14
  const id = (0, utils_1.useId)();
13
15
  const [expanded, setExpanded] = (0, react_1.useState)(defaultExpanded);
14
16
  const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)();
@@ -16,12 +18,12 @@ function Accordion(props) {
16
18
  setExpanded(defaultExpanded);
17
19
  }, [defaultExpanded]);
18
20
  return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, testIds.container, { css: {
19
- ...index_1.Css.bGray400.if(topBorder).bt.if(bottomBorder).bb.$,
20
- ...(size ? index_1.Css.wPx(accordionSizes[size]).$ : {}),
21
+ ...Css_1.Css.bGray400.if(topBorder).bt.if(bottomBorder).bb.$,
22
+ ...(size ? Css_1.Css.wPx(accordionSizes[size]).$ : {}),
21
23
  } }, { children: [(0, jsx_runtime_1.jsxs)("button", Object.assign({}, testIds.title, focusProps, { "aria-controls": id, "aria-expanded": expanded, disabled: disabled, css: {
22
- ...index_1.Css.df.jcsb.gap2.aic.w100.p2.baseMd.outline("none").addIn(":hover", index_1.Css.bgGray100.$).$,
23
- ...(disabled && index_1.Css.gray500.$),
24
- ...(isFocusVisible && index_1.Css.boxShadow(`inset 0 0 0 2px ${index_1.Palette.LightBlue700}`).$),
24
+ ...Css_1.Css.df.jcsb.gap2.aic.w100.p2.baseMd.outline("none").addIn(":hover", Css_1.Css.bgGray100.$).$,
25
+ ...(disabled && Css_1.Css.gray500.$),
26
+ ...(isFocusVisible && Css_1.Css.boxShadow(`inset 0 0 0 2px ${Css_1.Palette.LightBlue700}`).$),
25
27
  }, onClick: () => {
26
28
  setExpanded(!expanded);
27
29
  if (setExpandedIndex)
@@ -29,13 +31,13 @@ function Accordion(props) {
29
31
  } }, { children: [(0, jsx_runtime_1.jsx)("span", { children: title }, void 0), (0, jsx_runtime_1.jsx)("span", Object.assign({ css: {
30
32
  transition: "transform 250ms linear",
31
33
  transform: expanded ? "rotate(180deg)" : "rotate(0deg)",
32
- } }, { children: (0, jsx_runtime_1.jsx)(index_1.Icon, { icon: "chevronDown" }, void 0) }), void 0)] }), void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({}, testIds.details, { id: id, "aria-hidden": !expanded, css: {
34
+ } }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "chevronDown" }, void 0) }), void 0)] }), void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({}, testIds.details, { id: id, "aria-hidden": !expanded, css: {
33
35
  // Use max-height for grow/shrink animation (remove close animation for AccordionList to avoid delays)
34
- ...index_1.Css.overflowHidden
36
+ ...Css_1.Css.overflowHidden
35
37
  .maxhPx(1000)
36
38
  .add("transition", `max-height ${expanded || !index ? "250ms" : "0"} ease-in-out`).$,
37
- ...(!expanded || disabled ? index_1.Css.maxh0.$ : {}),
38
- } }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: index_1.Css.px2.pb2.pt1.$ }, { children: children }), void 0) }), void 0)] }), void 0));
39
+ ...(!expanded || disabled ? Css_1.Css.maxh0.$ : {}),
40
+ } }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.px2.pb2.pt1.$ }, { children: children }), void 0) }), void 0)] }), void 0));
39
41
  }
40
42
  exports.Accordion = Accordion;
41
43
  const accordionSizes = {
@@ -19,10 +19,6 @@ export interface BeamContextState {
19
19
  drawerCanCloseChecks: MutableRefObject<CanCloseCheck[]>;
20
20
  /** Checks when closing SuperDrawer Details, a double array to keep per-detail lists. */
21
21
  drawerCanCloseDetailsChecks: MutableRefObject<CanCloseCheck[][]>;
22
- /** The ref for defining the portal element's location for Tab actions */
23
- tabActionsRef: MutableRefObject<HTMLDivElement | null>;
24
- /** The div for Tab actions to portal into */
25
- tabActionsDiv: HTMLDivElement;
26
22
  }
27
23
  /** This is only exported internally, for useModal and useSuperDrawer, it's not a public API. */
28
24
  export declare const BeamContext: import("react").Context<BeamContextState>;
@@ -20,8 +20,6 @@ exports.BeamContext = (0, react_1.createContext)({
20
20
  drawerContentStack: new index_1.EmptyRef(),
21
21
  drawerCanCloseChecks: new index_1.EmptyRef(),
22
22
  drawerCanCloseDetailsChecks: new index_1.EmptyRef(),
23
- tabActionsRef: new index_1.EmptyRef(),
24
- tabActionsDiv: undefined,
25
23
  });
26
24
  function BeamProvider({ children, ...presentationProps }) {
27
25
  // We want the identity of these to be stable, b/c they end up being used as dependencies
@@ -42,8 +40,6 @@ function BeamProvider({ children, ...presentationProps }) {
42
40
  const drawerContentStackRef = (0, react_1.useRef)([]);
43
41
  const drawerCanCloseChecks = (0, react_1.useRef)([]);
44
42
  const drawerCanCloseDetailsChecks = (0, react_1.useRef)([]);
45
- const tabActionsRef = (0, react_1.useRef)(null);
46
- const tabActionsDiv = (0, react_1.useMemo)(() => document.createElement("div"), []);
47
43
  // We essentially expose the refs, but with our own getters/setters so that we can
48
44
  // have the setters call `tick` to re-render this Provider
49
45
  const context = (0, react_1.useMemo)(() => {
@@ -58,8 +54,6 @@ function BeamProvider({ children, ...presentationProps }) {
58
54
  modalFooterDiv,
59
55
  drawerCanCloseChecks,
60
56
  drawerCanCloseDetailsChecks,
61
- tabActionsRef,
62
- tabActionsDiv,
63
57
  };
64
58
  }, [modalBodyDiv, modalFooterDiv]);
65
59
  return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, Object.assign({ value: { ...context } }, { children: (0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({}, presentationProps, { children: (0, jsx_runtime_1.jsx)(form_state_1.AutoSaveStatusProvider, { children: (0, jsx_runtime_1.jsxs)(SnackbarContext_1.SnackbarProvider, { children: [(0, jsx_runtime_1.jsxs)(react_aria_1.OverlayProvider, { children: [children, modalRef.current && drawerContentStackRef.current.length === 0 && (0, jsx_runtime_1.jsx)(Modal_1.Modal, Object.assign({}, modalRef.current), void 0)] }, void 0), (0, jsx_runtime_1.jsx)(SuperDrawer_1.SuperDrawer, {}, void 0)] }, void 0) }, void 0) }), void 0) }), void 0));
@@ -12,4 +12,4 @@ export interface GridStyleDef {
12
12
  /** Enables cells Highlight and hover */
13
13
  cellHighlight?: boolean;
14
14
  }
15
- export declare const getTableStyles: (props?: GridStyleDef | undefined) => GridStyle;
15
+ export declare const getTableStyles: (props?: GridStyleDef) => GridStyle;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTableStyles = exports.cardStyle = exports.condensedStyle = exports.defaultStyle = void 0;
4
4
  const Css_1 = require("../../Css");
5
+ const utils_1 = require("../../utils");
5
6
  /** Our original table look & feel/style. */
6
7
  exports.defaultStyle = {
7
8
  rootCss: Css_1.Css.gray700.$,
@@ -43,9 +44,12 @@ exports.cardStyle = {
43
44
  };
44
45
  function memoizedTableStyles() {
45
46
  const cache = {};
46
- return (props) => {
47
- const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight } = props || {};
48
- const key = `${inlineEditing}|${grouped}|${rowHeight}`;
47
+ return (props = {}) => {
48
+ const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight = false } = props;
49
+ const key = (0, utils_1.safeKeys)(props)
50
+ .sort()
51
+ .map((k) => `${k}_${props[k]}`)
52
+ .join("|");
49
53
  if (!cache[key]) {
50
54
  const groupedLevels = {
51
55
  0: {
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, ReactNode, ReactPortal } from "react";
1
+ import { ReactNode } from "react";
2
2
  import type { IconKey } from "./";
3
3
  import { Margin, Only, Xss } from "../Css";
4
4
  export interface Tab<V extends string = string> {
@@ -17,6 +17,7 @@ export interface TabsProps<V extends string, X> {
17
17
  contentXss?: X;
18
18
  alwaysShowAllTabs?: boolean;
19
19
  includeBottomBorder?: boolean;
20
+ right?: ReactNode;
20
21
  }
21
22
  export interface RouteTabsProps<V extends string, X> extends Omit<TabsProps<V, X>, "onChange" | "selected" | "tabs"> {
22
23
  tabs: RouteTab<V>[];
@@ -129,5 +130,4 @@ export declare function getTabStyles(): {
129
130
  };
130
131
  };
131
132
  export declare function getNextTabValue<V extends string>(selected: V, key: "ArrowLeft" | "ArrowRight", tabs: Tab<V>[] | RouteTab<V>[]): V;
132
- export declare function TabActions({ children }: PropsWithChildren<{}>): ReactPortal;
133
133
  export {};
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TabActions = exports.getNextTabValue = exports.getTabStyles = exports.Tabs = exports.TabContent = exports.TabsWithContent = void 0;
3
+ exports.getNextTabValue = exports.getTabStyles = exports.Tabs = exports.TabContent = exports.TabsWithContent = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const change_case_1 = require("change-case");
6
6
  const react_1 = require("react");
7
7
  const react_aria_1 = require("react-aria");
8
- const react_dom_1 = require("react-dom");
9
8
  const react_router_1 = require("react-router");
10
9
  const react_router_dom_1 = require("react-router-dom");
11
- const BeamContext_1 = require("./BeamContext");
12
10
  const Css_1 = require("../Css");
13
11
  const utils_1 = require("../utils");
14
12
  const defaultTestId_1 = require("../utils/defaultTestId");
@@ -44,8 +42,7 @@ function TabContent(props) {
44
42
  exports.TabContent = TabContent;
45
43
  /** The top list of tabs. */
46
44
  function Tabs(props) {
47
- const { tabActionsRef, tabActionsDiv } = (0, BeamContext_1.useBeamContext)();
48
- const { ariaLabel, tabs, includeBottomBorder, ...others } = props;
45
+ const { ariaLabel, tabs, includeBottomBorder, right, ...others } = props;
49
46
  const location = (0, react_router_1.useLocation)();
50
47
  const selected = isRouteTabs(props)
51
48
  ? uniqueTabValue(props.tabs.find((t) => !!(0, react_router_1.matchPath)(location.pathname, { path: t.path, exact: true })) || props.tabs[0])
@@ -56,11 +53,6 @@ function Tabs(props) {
56
53
  const ref = (0, react_1.useRef)(null);
57
54
  // Whenever selected changes, reset active
58
55
  (0, react_1.useEffect)(() => setActive(selected), [selected]);
59
- (0, react_1.useEffect)(() => {
60
- if (tabActionsRef && tabActionsDiv) {
61
- tabActionsRef.current.appendChild(tabActionsDiv);
62
- }
63
- }, [tabActionsRef, tabActionsDiv]);
64
56
  // the active tab is highlighted, but not necessarily "selected"
65
57
  // the selected tab dictates what is displayed in the content panel
66
58
  function onKeyUp(e) {
@@ -87,7 +79,7 @@ function Tabs(props) {
87
79
  return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: [!hideTabs(props) && ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref, css: { ...Css_1.Css.dif.childGap1.$, ...(includeBottomBorder ? { ...Css_1.Css.bb.bGray200.$ } : {}) }, "aria-label": ariaLabel, role: "tablist" }, tid, { children: tabs.map((tab) => {
88
80
  const uniqueValue = uniqueTabValue(tab);
89
81
  return ((0, jsx_runtime_1.jsx)(TabImpl, Object.assign({ active: active === uniqueValue, focusProps: focusProps, isFocusVisible: isFocusVisible, onClick: onClick, onKeyUp: onKeyUp, onBlur: onBlur, tab: tab }, tid[(0, defaultTestId_1.defaultTestId)(uniqueValue)]), uniqueValue));
90
- }) }), void 0)), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.ml("auto").addIn("&>div", Css_1.Css.df.aic.childGap1.$).$, ref: tabActionsRef }, void 0)] }), void 0));
82
+ }) }), void 0)), right && (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.ml("auto").df.aic.gap1.$ }, { children: right }), void 0)] }), void 0));
91
83
  }
92
84
  exports.Tabs = Tabs;
93
85
  function TabImpl(props) {
@@ -157,14 +149,6 @@ function isRouteTab(tab) {
157
149
  function uniqueTabValue(tab) {
158
150
  return isRouteTab(tab) ? (0, change_case_1.camelCase)(tab.name) : tab.value;
159
151
  }
160
- function TabActions({ children }) {
161
- const { tabActionsDiv } = (0, BeamContext_1.useBeamContext)();
162
- if (!tabActionsDiv) {
163
- throw new Error("Tab Actions element is not defined");
164
- }
165
- return (0, react_dom_1.createPortal)(children, tabActionsDiv);
166
- }
167
- exports.TabActions = TabActions;
168
152
  // Determines whether we should hide the Tab panel. Returns true if there is only one enabled tab and `alwaysShowAllTabs` is falsey.
169
153
  function hideTabs(props) {
170
154
  return props.alwaysShowAllTabs ? false : props.tabs.filter((t) => !t.disabled).length === 1;
@@ -3,6 +3,8 @@ export * from "./Chips";
3
3
  export * from "./Table/GridTable";
4
4
  export * from "./ToggleChip";
5
5
  export * from "./ToggleChips";
6
+ export * from "./Accordion";
7
+ export * from "./AccordionList";
6
8
  export * from "./Alert";
7
9
  export * from "./AutoSaveIndicator";
8
10
  export { BeamProvider } from "./BeamContext";
@@ -27,9 +29,7 @@ export * from "./Stepper";
27
29
  export type { Step, StepperProps } from "./Stepper";
28
30
  export * from "./SuperDrawer";
29
31
  export * from "./Table";
30
- export { TabActions, TabContent, Tabs, TabsWithContent } from "./Tabs";
32
+ export { TabContent, Tabs, TabsWithContent } from "./Tabs";
31
33
  export type { RouteTab, RouteTabWithContent, Tab, TabWithContent } from "./Tabs";
32
34
  export * from "./Tag";
33
35
  export * from "./Tooltip";
34
- export * from "./Accordion";
35
- export * from "./AccordionList";
@@ -10,12 +10,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.TabsWithContent = exports.Tabs = exports.TabContent = exports.TabActions = exports.PresentationProvider = exports.NavLink = exports.BeamProvider = void 0;
13
+ exports.TabsWithContent = exports.Tabs = exports.TabContent = exports.PresentationProvider = exports.NavLink = exports.BeamProvider = void 0;
14
14
  __exportStar(require("./Chip"), exports);
15
15
  __exportStar(require("./Chips"), exports);
16
16
  __exportStar(require("./Table/GridTable"), exports);
17
17
  __exportStar(require("./ToggleChip"), exports);
18
18
  __exportStar(require("./ToggleChips"), exports);
19
+ __exportStar(require("./Accordion"), exports);
20
+ __exportStar(require("./AccordionList"), exports);
19
21
  __exportStar(require("./Alert"), exports);
20
22
  __exportStar(require("./AutoSaveIndicator"), exports);
21
23
  var BeamContext_1 = require("./BeamContext");
@@ -43,11 +45,8 @@ __exportStar(require("./Stepper"), exports);
43
45
  __exportStar(require("./SuperDrawer"), exports);
44
46
  __exportStar(require("./Table"), exports);
45
47
  var Tabs_1 = require("./Tabs");
46
- Object.defineProperty(exports, "TabActions", { enumerable: true, get: function () { return Tabs_1.TabActions; } });
47
48
  Object.defineProperty(exports, "TabContent", { enumerable: true, get: function () { return Tabs_1.TabContent; } });
48
49
  Object.defineProperty(exports, "Tabs", { enumerable: true, get: function () { return Tabs_1.Tabs; } });
49
50
  Object.defineProperty(exports, "TabsWithContent", { enumerable: true, get: function () { return Tabs_1.TabsWithContent; } });
50
51
  __exportStar(require("./Tag"), exports);
51
52
  __exportStar(require("./Tooltip"), exports);
52
- __exportStar(require("./Accordion"), exports);
53
- __exportStar(require("./AccordionList"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.182.0",
3
+ "version": "2.183.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",