@homebound/beam 2.199.1 → 2.200.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.
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from "react";
2
+ import { OverlayTriggerProps } from "./internal/OverlayTrigger";
3
+ export interface ButtonModalProps extends Pick<OverlayTriggerProps, "trigger" | "placement" | "disabled" | "tooltip"> {
4
+ content: ReactNode;
5
+ title?: string;
6
+ storybookDefaultOpen?: boolean;
7
+ }
8
+ export declare function ButtonModal(props: ButtonModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ButtonModal = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_aria_1 = require("react-aria");
7
+ const react_stately_1 = require("react-stately");
8
+ const OverlayTrigger_1 = require("./internal/OverlayTrigger");
9
+ const utils_1 = require("../utils");
10
+ const ContextualModal_1 = require("./internal/ContextualModal");
11
+ function ButtonModal(props) {
12
+ const { storybookDefaultOpen, trigger, disabled, content, title } = props;
13
+ const state = (0, react_stately_1.useMenuTriggerState)({ isOpen: storybookDefaultOpen });
14
+ const buttonRef = (0, react_1.useRef)(null);
15
+ const { menuTriggerProps } = (0, react_aria_1.useMenuTrigger)({ isDisabled: !!disabled }, state, buttonRef);
16
+ const tid = (0, utils_1.useTestIds)(props, (0, OverlayTrigger_1.isTextButton)(trigger) ? trigger.label : (0, OverlayTrigger_1.isIconButton)(trigger) ? trigger.icon : trigger.name);
17
+ return ((0, jsx_runtime_1.jsx)(OverlayTrigger_1.OverlayTrigger, Object.assign({}, props, { menuTriggerProps: menuTriggerProps, state: state, buttonRef: buttonRef }, tid, { children: (0, jsx_runtime_1.jsx)(ContextualModal_1.ContextualModal, { content: content, title: title }, void 0) }), void 0));
18
+ }
19
+ exports.ButtonModal = ButtonModal;
@@ -1,10 +1,9 @@
1
- import { GridColumnWithId } from "../types";
2
1
  import { Properties } from "../../../Css";
3
2
  interface SortHeaderProps {
4
3
  content: string;
5
4
  xss?: Properties;
6
5
  iconOnLeft?: boolean;
7
- column: GridColumnWithId<any>;
6
+ sortKey: string;
8
7
  }
9
8
  /**
10
9
  * Wraps column header names with up/down sorting icons.
@@ -20,13 +20,12 @@ const useTestIds_1 = require("../../../utils/useTestIds");
20
20
  * current sort state + `toggleSort` function
21
21
  */
22
22
  function SortHeader(props) {
23
- const { content, xss, iconOnLeft = false, column } = props;
23
+ const { content, xss, iconOnLeft = false, sortKey } = props;
24
24
  const { isHovered, hoverProps } = (0, hooks_1.useHover)({});
25
- const ourSortKey = column.serverSideSortKey || column.id;
26
25
  const { tableState } = (0, react_1.useContext)(TableState_1.TableStateContext);
27
26
  const current = (0, hooks_1.useComputed)(() => { var _a; return (_a = tableState.sortState) === null || _a === void 0 ? void 0 : _a.current; }, [tableState]);
28
- const sorted = ourSortKey === (current === null || current === void 0 ? void 0 : current.columnId) ? current === null || current === void 0 ? void 0 : current.direction : undefined;
29
- const toggleSort = (0, react_1.useCallback)(() => tableState.setSortKey(ourSortKey), [ourSortKey, tableState]);
27
+ const sorted = sortKey === (current === null || current === void 0 ? void 0 : current.columnId) ? current === null || current === void 0 ? void 0 : current.direction : undefined;
28
+ const toggleSort = (0, react_1.useCallback)(() => tableState.setSortKey(sortKey), [sortKey, tableState]);
30
29
  const tid = (0, useTestIds_1.useTestIds)(props, "sortHeader");
31
30
  const icon = ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.$ }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, Object.assign({ icon: sorted === "DESC" ? "sortDown" : "sortUp", color: sorted !== undefined ? Css_1.Palette.LightBlue700 : Css_1.Palette.Gray400, xss: {
32
31
  ...Css_1.Css.ml1.if(iconOnLeft).mr1.ml0.$,
@@ -7,7 +7,7 @@ const Css_1 = require("../../../Css");
7
7
  const getInteractiveElement_1 = require("../../../utils/getInteractiveElement");
8
8
  /** If a column def return just string text for a given row, apply some default styling. */
9
9
  function toContent(maybeContent, isHeader, canSortColumn, isClientSideSorting, style, as, alignment, column) {
10
- var _a, _b;
10
+ var _a, _b, _c;
11
11
  let content = isGridCellContent(maybeContent) ? maybeContent.content : maybeContent;
12
12
  if (typeof content === "function") {
13
13
  // Actually create the JSX by calling `content()` here (which should be as late as
@@ -32,9 +32,9 @@ function toContent(maybeContent, isHeader, canSortColumn, isClientSideSorting, s
32
32
  })
33
33
  : content;
34
34
  if (content && typeof content === "string" && isHeader && canSortColumn) {
35
- return (0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right", column: column }, void 0);
35
+ return ((0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right", sortKey: (_b = column.serverSideSortKey) !== null && _b !== void 0 ? _b : column.id }, void 0));
36
36
  }
37
- else if (content && ((_b = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _b === void 0 ? void 0 : _b.wrap) === false && typeof content === "string") {
37
+ else if (content && ((_c = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _c === void 0 ? void 0 : _c.wrap) === false && typeof content === "string") {
38
38
  // In order to truncate the text properly, then we need to wrap it in another element
39
39
  // as our cell element is a flex container, which don't allow for applying truncation styles directly on it.
40
40
  return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.truncate.mw0.$, title: content }, { children: content }), void 0));
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ export interface ContextualModalProps {
3
+ content: ReactNode;
4
+ title?: string;
5
+ }
6
+ export declare function ContextualModal(props: ContextualModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContextualModal = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const react_aria_1 = require("react-aria");
6
+ const Css_1 = require("../../Css");
7
+ const utils_1 = require("../../utils");
8
+ function ContextualModal(props) {
9
+ const { content, title } = props;
10
+ const tid = (0, utils_1.useTestIds)(props, "popup");
11
+ return ((0, jsx_runtime_1.jsx)(react_aria_1.FocusScope, Object.assign({ restoreFocus: true, autoFocus: true }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.p3.df.fdc.gap3.bgWhite.bshModal.br4.maxh("inherit").overflowAuto.$ }, { children: [title && ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.lg.tc.$ }, tid.title, { children: title }), void 0)), (0, jsx_runtime_1.jsx)("div", Object.assign({}, tid.content, { children: content }), void 0)] }), void 0) }), void 0));
12
+ }
13
+ exports.ContextualModal = ContextualModal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.199.1",
3
+ "version": "2.200.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",