@homebound/beam 2.129.0 → 2.132.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.
@@ -6,6 +6,7 @@ const react_1 = require("react");
6
6
  const react_aria_1 = require("react-aria");
7
7
  const Modal_1 = require("./Modal/Modal");
8
8
  const PresentationContext_1 = require("./PresentationContext");
9
+ const SnackbarContext_1 = require("./Snackbar/SnackbarContext");
9
10
  const SuperDrawer_1 = require("./SuperDrawer/SuperDrawer");
10
11
  const index_1 = require("../utils/index");
11
12
  /** This is only exported internally, for useModal and useSuperDrawer, it's not a public API. */
@@ -55,7 +56,7 @@ function BeamProvider({ children, ...presentationProps }) {
55
56
  tabActionsDiv,
56
57
  };
57
58
  }, [modalBodyDiv, modalFooterDiv]);
58
- return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, Object.assign({ value: { ...context } }, { children: (0, jsx_runtime_1.jsxs)(PresentationContext_1.PresentationProvider, Object.assign({}, presentationProps, { 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));
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.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));
59
60
  }
60
61
  exports.BeamProvider = BeamProvider;
61
62
  /** Looks like a ref, but invokes a re-render on set (w/o changing the setter identity). */
@@ -4,10 +4,10 @@ exports.Button = void 0;
4
4
  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
- const react_router_dom_1 = require("react-router-dom");
8
7
  const components_1 = require("./");
9
8
  const Css_1 = require("../Css");
10
9
  const utils_1 = require("../utils");
10
+ const getInteractiveElement_1 = require("../utils/getInteractiveElement");
11
11
  const useTestIds_1 = require("../utils/useTestIds");
12
12
  function Button(props) {
13
13
  const { onClick: onPress, disabled, endAdornment, menuTriggerProps, tooltip, openInNew, download, contrast = false, ...otherProps } = props;
@@ -38,8 +38,9 @@ function Button(props) {
38
38
  ...buttonProps,
39
39
  ...focusProps,
40
40
  ...hoverProps,
41
+ className: typeof onPress === "string" ? components_1.navLink : undefined,
41
42
  css: {
42
- ...Css_1.Css.buttonBase.$,
43
+ ...Css_1.Css.buttonBase.tt("inherit").$,
43
44
  ...baseStyles,
44
45
  ...(isHovered && !isPressed ? hoverStyles : {}),
45
46
  ...(isPressed ? pressedStyles : {}),
@@ -48,12 +49,11 @@ function Button(props) {
48
49
  },
49
50
  ...tid,
50
51
  };
51
- const button = typeof onPress === "string" ? ((0, utils_1.isAbsoluteUrl)(onPress) || openInNew || download ? ((0, jsx_runtime_1.jsx)("a", Object.assign({}, buttonAttrs, { href: onPress, className: components_1.navLink }, (download ? { download: "" } : { target: "_blank", rel: "noreferrer noopener" }), { children: buttonContent }), void 0)) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({}, buttonAttrs, { to: onPress, className: components_1.navLink }, { children: buttonContent }), void 0))) : ((0, jsx_runtime_1.jsx)("button", Object.assign({}, buttonAttrs, { children: buttonContent }), void 0));
52
52
  // If we're disabled b/c of a non-boolean ReactNode, or the caller specified tooltip text, then show it in a tooltip
53
53
  return (0, components_1.maybeTooltip)({
54
54
  title: (0, components_1.resolveTooltip)(disabled, tooltip),
55
55
  placement: "top",
56
- children: button,
56
+ children: (0, getInteractiveElement_1.getButtonOrLink)(buttonContent, onPress, buttonAttrs, openInNew, download),
57
57
  });
58
58
  }
59
59
  exports.Button = Button;
@@ -0,0 +1,6 @@
1
+ import { SnackbarNoticeProps } from "./SnackbarNotice";
2
+ interface SnackbarProps {
3
+ notices: SnackbarNoticeProps[];
4
+ }
5
+ export declare function Snackbar({ notices }: SnackbarProps): import("@emotion/react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Snackbar = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const SnackbarNotice_1 = require("./SnackbarNotice");
6
+ const Css_1 = require("../../Css");
7
+ function Snackbar({ notices }) {
8
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.fixed.bottom3.right3.df.fdc.aife.gapPx(12).$ }, { children: notices.map((data) => ((0, jsx_runtime_1.jsx)(SnackbarNotice_1.SnackbarNotice, Object.assign({}, data), data.id))) }), void 0));
9
+ }
10
+ exports.Snackbar = Snackbar;
@@ -0,0 +1,8 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ import { SnackbarNoticeProps } from "./SnackbarNotice";
3
+ export declare type SnackbarContextProps = {
4
+ setNotices: React.Dispatch<React.SetStateAction<SnackbarNoticeProps[]>>;
5
+ };
6
+ export declare const SnackbarContext: React.Context<SnackbarContextProps>;
7
+ export declare function SnackbarProvider(props: PropsWithChildren<{}>): import("@emotion/react/jsx-runtime").JSX.Element;
8
+ export declare function useSnackbarContext(): SnackbarContextProps;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSnackbarContext = exports.SnackbarProvider = exports.SnackbarContext = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const Snackbar_1 = require("./Snackbar");
7
+ exports.SnackbarContext = (0, react_1.createContext)({ setNotices: () => { } });
8
+ function SnackbarProvider(props) {
9
+ const [notices, setNotices] = (0, react_1.useState)([]);
10
+ const contextValue = (0, react_1.useMemo)(() => ({ setNotices }), []);
11
+ return ((0, jsx_runtime_1.jsxs)(exports.SnackbarContext.Provider, Object.assign({ value: contextValue }, { children: [props.children, (0, jsx_runtime_1.jsx)(Snackbar_1.Snackbar, { notices: notices }, void 0)] }), void 0));
12
+ }
13
+ exports.SnackbarProvider = SnackbarProvider;
14
+ function useSnackbarContext() {
15
+ return (0, react_1.useContext)(exports.SnackbarContext);
16
+ }
17
+ exports.useSnackbarContext = useSnackbarContext;
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from "react";
2
+ import { ButtonProps } from "../Button";
3
+ export declare type SnackbarNoticeTypes = "error" | "warning" | "success" | "info";
4
+ export interface SnackbarNoticeProps {
5
+ /** Adds action button to the right of the notice */
6
+ action?: Pick<ButtonProps, "label" | "onClick" | "variant">;
7
+ /** Does not allow the user to close the notice manually. Notice will fade away in 10s. Value will be ignored if 'persistent' is set to 'true'. */
8
+ hideCloseButton?: boolean;
9
+ message: ReactNode;
10
+ /** This notice will persist on the screen until systematically closed by the app or by the user clicking the close button. */
11
+ persistent?: boolean;
12
+ /** Defines the icon that will show on the left side of the notification. */
13
+ icon?: SnackbarNoticeTypes;
14
+ /** Unique identifier to allow notice to close itself */
15
+ id: string;
16
+ /** Removes the snackbar notice from the stack */
17
+ onClose: () => void;
18
+ }
19
+ export declare function SnackbarNotice(props: SnackbarNoticeProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SnackbarNotice = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const Button_1 = require("../Button");
6
+ const Icon_1 = require("../Icon");
7
+ const IconButton_1 = require("../IconButton");
8
+ const Css_1 = require("../../Css");
9
+ const utils_1 = require("../../utils");
10
+ function SnackbarNotice(props) {
11
+ const { icon, message, action, hideCloseButton, persistent, onClose } = props;
12
+ const tid = (0, utils_1.useTestIds)(props, "snackbar");
13
+ // Only allow the "close" button to be hidden if not a `persistent` notice. Otherwise we could get in a state where the user cannot remove the notice from the screen.
14
+ const reallyHideClose = hideCloseButton && !persistent;
15
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.white.bgGray800.br4.base.df.aic.maxwPx(420).$ }, tid, { children: [icon && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.plPx(12).$ }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, Object.assign({ icon: typeToIcon[icon] }, tid.icon), void 0) }), void 0)), (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp3.pr2.myPx(12).plPx(icon ? 8 : 16).$ }, (typeof message === "string" ? { title: message } : undefined), tid.message, { children: message }), void 0), (action || !reallyHideClose) && ((0, jsx_runtime_1.jsxs)("span", Object.assign({ css: Css_1.Css.fs0.df.aic.$ }, { children: [action && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.ttu.sm.prPx(!reallyHideClose && action.variant !== "text" ? 4 : 8).$ }, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ contrast: true }, action, tid.action), void 0) }), void 0)), !reallyHideClose && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.pr1.add("lineHeight", 0).$ }, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({ icon: "x", contrast: true, onClick: onClose }, tid.close), void 0) }), void 0))] }), void 0))] }), void 0));
16
+ }
17
+ exports.SnackbarNotice = SnackbarNotice;
18
+ const typeToIcon = {
19
+ error: "xCircle",
20
+ warning: "error",
21
+ success: "checkCircle",
22
+ info: "infoCircle",
23
+ };
@@ -0,0 +1,2 @@
1
+ export { useSnackbar } from "./useSnackbar";
2
+ export type { TriggerNoticeProps } from "./useSnackbar";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSnackbar = void 0;
4
+ var useSnackbar_1 = require("./useSnackbar");
5
+ Object.defineProperty(exports, "useSnackbar", { enumerable: true, get: function () { return useSnackbar_1.useSnackbar; } });
@@ -0,0 +1,12 @@
1
+ import { SnackbarNoticeProps } from "./SnackbarNotice";
2
+ export interface UseSnackbarHook {
3
+ triggerNotice: (props: TriggerNoticeProps) => {
4
+ close: () => void;
5
+ };
6
+ closeNotice: (id: string) => void;
7
+ }
8
+ export declare function useSnackbar(): UseSnackbarHook;
9
+ export interface TriggerNoticeProps extends Omit<SnackbarNoticeProps, "id" | "onClose"> {
10
+ id?: string;
11
+ onClose?: () => void;
12
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSnackbar = void 0;
4
+ const react_1 = require("react");
5
+ const SnackbarContext_1 = require("./SnackbarContext");
6
+ const utils_1 = require("../../utils");
7
+ function useSnackbar() {
8
+ const { setNotices } = (0, SnackbarContext_1.useSnackbarContext)();
9
+ const onClose = (0, react_1.useCallback)((noticeId) => {
10
+ setNotices((prev) => {
11
+ let returnValue = prev;
12
+ // check to see if the notice is still in our existing stack, if so then remove it. Otherwise it was manually closed, so return the existing value.
13
+ if (prev.some(({ id }) => id === noticeId)) {
14
+ returnValue = prev.filter(({ id }) => id !== noticeId);
15
+ }
16
+ // For good measure, reset the snackbarId when notices array is emptied.
17
+ if (returnValue.length === 0) {
18
+ snackbarId = 1;
19
+ }
20
+ return returnValue;
21
+ });
22
+ }, []);
23
+ const triggerNotice = (0, react_1.useCallback)((props) => {
24
+ var _a;
25
+ // Sets `noticeId` to the current value of `snackbarId` and then increments.
26
+ const noticeId = (_a = props.id) !== null && _a !== void 0 ? _a : `beamSnackbar:${snackbarId++}`;
27
+ let maybeTimeout;
28
+ if (!props.persistent) {
29
+ maybeTimeout = window.setTimeout(() => {
30
+ onClose(noticeId);
31
+ // Auto close in 10s
32
+ }, 10000);
33
+ }
34
+ setNotices((prev) => prev.concat({
35
+ ...props,
36
+ id: noticeId,
37
+ onClose: () => {
38
+ // Because we reset the `snackbarId` if the notices array is empty, then we need to call `clearTimeout` to ensure we don't accidentally close the wrong notice
39
+ clearTimeout(maybeTimeout);
40
+ onClose(noticeId);
41
+ (0, utils_1.maybeCall)(props.onClose);
42
+ },
43
+ }));
44
+ return {
45
+ close: () => {
46
+ // Because we reset the `snackbarId` if the notices array is empty, then we need to call `clearTimeout` to ensure we don't accidentally close the wrong notice
47
+ clearTimeout(maybeTimeout);
48
+ onClose(noticeId);
49
+ },
50
+ };
51
+ }, [onClose, setNotices]);
52
+ const closeNotice = (0, react_1.useCallback)((id) => onClose(id), [onClose]);
53
+ return { triggerNotice, closeNotice };
54
+ }
55
+ exports.useSnackbar = useSnackbar;
56
+ let snackbarId = 1;
@@ -121,6 +121,7 @@ export declare type GridSortConfig<S> = {
121
121
  on: "client";
122
122
  /** The optional initial column (index in columns) and direction to sort. */
123
123
  initial?: [S | GridColumn<any>, Direction] | undefined;
124
+ caseSensitive?: boolean;
124
125
  } | {
125
126
  on: "server";
126
127
  /** The current sort by value + direction (if server-side sorting). */
@@ -308,6 +309,8 @@ export declare type GridCellContent = {
308
309
  typeScale?: Typography;
309
310
  /** Allows the cell to stay in place when the user scrolls horizontally */
310
311
  sticky?: "left" | "right";
312
+ /** If provided, content of the cell will be wrapped within a <button /> or <a /> tag depending on if the value is a function or a string. */
313
+ onClick?: () => {} | string;
311
314
  };
312
315
  declare type MaybeFn<T> = T | (() => T);
313
316
  /**
@@ -45,6 +45,7 @@ const Css_1 = require("../../Css");
45
45
  const hooks_1 = require("../../hooks");
46
46
  const useRenderCount_1 = require("../../hooks/useRenderCount");
47
47
  const utils_1 = require("../../utils");
48
+ const getInteractiveElement_1 = require("../../utils/getInteractiveElement");
48
49
  const shallowEqual_1 = require("../../utils/shallowEqual");
49
50
  const _1 = require(".");
50
51
  exports.ASC = "ASC";
@@ -113,14 +114,14 @@ function GridTable(props) {
113
114
  const columnSizes = (0, columnSizes_1.useSetupColumnSizes)(style, columns, tableRef, resizeTarget);
114
115
  // Make a single copy of our current collapsed state, so we'll have a single observer.
115
116
  const collapsedIds = (0, hooks_1.useComputed)(() => rowState.collapsedIds, [rowState]);
116
- const [sortState, setSortKey, sortOn] = (0, useSortState_1.useSortState)(columns, props.sorting);
117
+ const [sortState, setSortKey, sortOn, caseSensitive] = (0, useSortState_1.useSortState)(columns, props.sorting);
117
118
  const maybeSorted = (0, react_1.useMemo)(() => {
118
119
  if (sortOn === "client" && sortState) {
119
120
  // If using client-side sort, the sortState use S = number
120
- return (0, sortRows_1.sortRows)(columns, rows, sortState);
121
+ return (0, sortRows_1.sortRows)(columns, rows, sortState, caseSensitive);
121
122
  }
122
123
  return rows;
123
- }, [columns, rows, sortOn, sortState]);
124
+ }, [columns, rows, sortOn, sortState, caseSensitive]);
124
125
  let hasTotalsRow = false;
125
126
  // Filter rows - ensures parent rows remain in the list if any children match the filter.
126
127
  const filterRows = (0, react_1.useCallback)((acc, row) => {
@@ -643,9 +644,9 @@ function isJSX(content) {
643
644
  return typeof content === "object" && content && "type" in content && "props" in content;
644
645
  }
645
646
  /** If a column def return just string text for a given row, apply some default styling. */
646
- function toContent(content, isHeader, canSortColumn, isClientSideSorting, style, as, alignment) {
647
- var _a;
648
- content = isGridCellContent(content) ? content.content : content;
647
+ function toContent(maybeContent, isHeader, canSortColumn, isClientSideSorting, style, as, alignment) {
648
+ var _a, _b;
649
+ let content = isGridCellContent(maybeContent) ? maybeContent.content : maybeContent;
649
650
  if (typeof content === "function") {
650
651
  // Actually create the JSX by calling `content()` here (which should be as late as
651
652
  // possible, i.e. only for visible rows if we're in a virtual table).
@@ -662,11 +663,19 @@ function toContent(content, isHeader, canSortColumn, isClientSideSorting, style,
662
663
  // for those tables.
663
664
  throw new Error("GridTables with as=virtual & sortable columns should use functions that return JSX, instead of JSX");
664
665
  }
666
+ content =
667
+ isGridCellContent(maybeContent) && !!maybeContent.onClick
668
+ ? (0, getInteractiveElement_1.getButtonOrLink)(content, maybeContent.onClick, {
669
+ css: Css_1.Css.maxw100.lightBlue700.if(((_a = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _a === void 0 ? void 0 : _a.wrap) === false).truncate.$,
670
+ })
671
+ : content;
665
672
  if (content && typeof content === "string" && isHeader && canSortColumn) {
666
673
  return (0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right" }, void 0);
667
674
  }
668
- else if (content && typeof content === "string" && ((_a = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _a === void 0 ? void 0 : _a.wrap) === false) {
669
- return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.mw0.truncate.$, title: content }, { children: content }), void 0));
675
+ 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") {
676
+ // In order to truncate the text properly, then we need to wrap it in another element
677
+ // as our cell element is a flex container, which don't allow for applying truncation styles directly on it.
678
+ return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.truncate.mw0.$, title: content }, { children: content }), void 0));
670
679
  }
671
680
  else if (style.emptyCell && isContentEmpty(content)) {
672
681
  // If the content is empty and the user specified an `emptyCell` node, return that.
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from "react";
2
2
  import { GridCellContent, GridColumn, GridDataRow, Kinded } from "./GridTable";
3
3
  import { SortOn, SortState } from "./useSortState";
4
- export declare function sortRows<R extends Kinded>(columns: GridColumn<R>[], rows: GridDataRow<R>[], sortState: SortState<number>): GridDataRow<R>[];
4
+ export declare function sortRows<R extends Kinded>(columns: GridColumn<R>[], rows: GridDataRow<R>[], sortState: SortState<number>, caseSensitive: boolean): GridDataRow<R>[];
5
5
  export declare function ensureClientSideSortValueIsSortable(sortOn: SortOn, isHeader: boolean, column: GridColumn<any>, idx: number, maybeContent: ReactNode | GridCellContent): void;
@@ -3,26 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureClientSideSortValueIsSortable = exports.sortRows = void 0;
4
4
  const GridTable_1 = require("./GridTable");
5
5
  // Returns a shallow copy of the `rows` parameter sorted based on `sortState`
6
- function sortRows(columns, rows, sortState) {
7
- const sorted = sortBatch(columns, rows, sortState);
6
+ function sortRows(columns, rows, sortState, caseSensitive) {
7
+ const sorted = sortBatch(columns, rows, sortState, caseSensitive);
8
8
  // Recursively sort child rows
9
9
  sorted.forEach((row, i) => {
10
10
  if (row.children) {
11
- sorted[i].children = sortRows(columns, row.children, sortState);
11
+ sorted[i].children = sortRows(columns, row.children, sortState, caseSensitive);
12
12
  }
13
13
  });
14
14
  return sorted;
15
15
  }
16
16
  exports.sortRows = sortRows;
17
- function sortBatch(columns, batch, sortState) {
17
+ function sortBatch(columns, batch, sortState, caseSensitive) {
18
18
  // When client-side sort, the sort value is the column index
19
19
  const [value, direction] = sortState;
20
20
  const column = columns[value];
21
21
  const invert = direction === "DESC";
22
22
  // Make a shallow copy for sorting to avoid mutating the original list
23
23
  return [...batch].sort((a, b) => {
24
- const v1 = sortValue((0, GridTable_1.applyRowFn)(column, a, {}, 0));
25
- const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}, 0));
24
+ const v1 = sortValue((0, GridTable_1.applyRowFn)(column, a, {}, 0), caseSensitive);
25
+ const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}, 0), caseSensitive);
26
26
  const v1e = v1 === null || v1 === undefined;
27
27
  const v2e = v2 === null || v2 === undefined;
28
28
  if (a.pin || b.pin) {
@@ -43,7 +43,7 @@ function sortBatch(columns, batch, sortState) {
43
43
  });
44
44
  }
45
45
  /** Look at a row and get its sort value. */
46
- function sortValue(value) {
46
+ function sortValue(value, caseSensitive) {
47
47
  // Check sortValue and then fallback on value
48
48
  let maybeFn = value;
49
49
  if (value && typeof value === "object") {
@@ -60,13 +60,14 @@ function sortValue(value) {
60
60
  }
61
61
  // Watch for functions that need to read from a potentially-changing proxy
62
62
  if (maybeFn instanceof Function) {
63
- return maybeFn();
63
+ maybeFn = maybeFn();
64
64
  }
65
- return maybeFn;
65
+ // If it is a string, then always lower case it for comparisons
66
+ return typeof maybeFn === "string" && !caseSensitive ? maybeFn.toLowerCase() : maybeFn;
66
67
  }
67
68
  function ensureClientSideSortValueIsSortable(sortOn, isHeader, column, idx, maybeContent) {
68
69
  if (process.env.NODE_ENV !== "production" && !isHeader && sortOn === "client" && column.clientSideSort !== false) {
69
- const value = sortValue(maybeContent);
70
+ const value = sortValue(maybeContent, false);
70
71
  if (!canClientSideSort(value)) {
71
72
  throw new Error(`Column ${idx} passed an unsortable value, use GridCellContent or clientSideSort=false`);
72
73
  }
@@ -10,5 +10,5 @@ import { Direction, GridColumn, GridSortConfig, Kinded } from "./GridTable";
10
10
  export declare type SortState<S> = readonly [S, Direction];
11
11
  export declare type SortOn = "client" | "server" | undefined;
12
12
  /** Small custom hook that wraps the "setSortColumn inverts the current sort" logic. */
13
- export declare function useSortState<R extends Kinded, S>(columns: GridColumn<R, S>[], sorting?: GridSortConfig<S>): [SortState<S> | undefined, (value: S) => void, SortOn];
13
+ export declare function useSortState<R extends Kinded, S>(columns: GridColumn<R, S>[], sorting?: GridSortConfig<S>): [SortState<S> | undefined, (value: S) => void, SortOn, boolean];
14
14
  export declare function deriveSortState<S>(currentSortState: SortState<S> | undefined, clickedKey: S, initialSortState: SortState<S> | undefined): SortState<S> | undefined;
@@ -47,7 +47,9 @@ function useSortState(columns, sorting) {
47
47
  },
48
48
  // Note that sorting.onSort is not listed here, so we bind to whatever the 1st sorting.onSort was
49
49
  [initialSortState, sortState, onSort]);
50
- return [sortState, setSortKey, sorting === null || sorting === void 0 ? void 0 : sorting.on];
50
+ // If sorting is done on the client, the by default the sort will NOT be case sensitive
51
+ const caseSensitive = (sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client" ? !!sorting.caseSensitive : false;
52
+ return [sortState, setSortKey, sorting === null || sorting === void 0 ? void 0 : sorting.on, caseSensitive];
51
53
  }
52
54
  exports.useSortState = useSortState;
53
55
  // Exported for testing purposes
@@ -19,6 +19,7 @@ export * from "./Modal";
19
19
  export * from "./Modal/useModal";
20
20
  export { NavLink } from "./NavLink";
21
21
  export { PresentationProvider } from "./PresentationContext";
22
+ export * from "./Snackbar";
22
23
  export * from "./Stepper";
23
24
  export * from "./SuperDrawer";
24
25
  export * from "./Table";
@@ -35,6 +35,7 @@ var NavLink_1 = require("./NavLink");
35
35
  Object.defineProperty(exports, "NavLink", { enumerable: true, get: function () { return NavLink_1.NavLink; } });
36
36
  var PresentationContext_1 = require("./PresentationContext");
37
37
  Object.defineProperty(exports, "PresentationProvider", { enumerable: true, get: function () { return PresentationContext_1.PresentationProvider; } });
38
+ __exportStar(require("./Snackbar"), exports);
38
39
  __exportStar(require("./Stepper"), exports);
39
40
  __exportStar(require("./SuperDrawer"), exports);
40
41
  __exportStar(require("./Table"), exports);
@@ -23,7 +23,7 @@ function OverlayTrigger(props) {
23
23
  placement: (placement ? `bottom ${placement}` : "bottom left"),
24
24
  });
25
25
  const tid = (0, utils_1.useTestIds)(props, isTextButton(trigger) ? (0, defaultTestId_1.defaultTestId)(trigger.label) : trigger.icon);
26
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.relative.dib.$ }, { children: [isTextButton(trigger) ? ((0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ variant: "secondary" }, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef, endAdornment: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: state.isOpen ? "chevronUp" : "chevronDown" }, void 0), disabled: disabled, tooltip: tooltip }, tid), void 0)) : ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({}, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef }, tid), void 0)), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, Object.assign({ triggerRef: buttonRef, popoverRef: popoverRef, positionProps: positionProps, onClose: () => state.close(), isOpen: state.isOpen }, { children: children }), void 0))] }), void 0));
26
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.relative.dib.$ }, { children: [isTextButton(trigger) ? ((0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ variant: "secondary" }, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef, endAdornment: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: state.isOpen ? "chevronUp" : "chevronDown" }, void 0), disabled: disabled, tooltip: tooltip, onClick: utils_1.noop }, tid), void 0)) : ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({}, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef }, tid, { onClick: utils_1.noop }), void 0)), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, Object.assign({ triggerRef: buttonRef, popoverRef: popoverRef, positionProps: positionProps, onClose: () => state.close(), isOpen: state.isOpen }, { children: children }), void 0))] }), void 0));
27
27
  }
28
28
  exports.OverlayTrigger = OverlayTrigger;
29
29
  function isTextButton(trigger) {
@@ -16,7 +16,7 @@ export interface BeamButtonProps {
16
16
  */
17
17
  disabled?: boolean | ReactNode;
18
18
  /** If function, then it is the handler that is called when the press is released over the target. Otherwise if string, it is the URL path for the link */
19
- onClick?: ((e: PressEvent) => void) | string;
19
+ onClick: ((e: PressEvent) => void) | string;
20
20
  /** Text to be shown via a tooltip when the user hovers over the button */
21
21
  tooltip?: ReactNode;
22
22
  /** Whether to open link in a new tab. This only effects the element if the `onClick` is a `string`/URL. */
@@ -0,0 +1,3 @@
1
+ import { PressEvent } from "@react-types/shared";
2
+ import { HTMLAttributes, ReactNode } from "react";
3
+ export declare function getButtonOrLink(content: ReactNode, onClick: ((e: PressEvent) => void) | string, attrs: HTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, openInNew?: boolean, downloadLink?: boolean): JSX.Element;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getButtonOrLink = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const react_router_dom_1 = require("react-router-dom");
6
+ const index_1 = require("./index");
7
+ function getButtonOrLink(content, onClick, attrs, openInNew = false, downloadLink = false) {
8
+ return typeof onClick === "string" ? ((0, index_1.isAbsoluteUrl)(onClick) || openInNew || downloadLink ? ((0, jsx_runtime_1.jsx)("a", Object.assign({}, attrs, { href: onClick }, (downloadLink ? { download: "" } : { target: "_blank", rel: "noreferrer noopener" }), { children: content }), void 0)) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({}, attrs, { to: onClick }, { children: content }), void 0))) : ((0, jsx_runtime_1.jsx)("button", Object.assign({}, attrs, { children: content }), void 0));
9
+ }
10
+ exports.getButtonOrLink = getButtonOrLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.129.0",
3
+ "version": "2.132.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",