@homebound/beam 2.120.0 → 2.122.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.
- package/dist/components/IconButton.d.ts +5 -0
- package/dist/components/IconButton.js +8 -4
- package/dist/components/Modal/TestModalContent.js +1 -1
- package/dist/components/Table/GridTable.d.ts +2 -1
- package/dist/components/Table/GridTable.js +2 -7
- package/dist/components/Table/columns.js +2 -2
- package/dist/components/Table/index.d.ts +2 -2
- package/dist/components/Table/index.js +1 -2
- package/dist/components/Table/simpleHelpers.d.ts +4 -12
- package/dist/components/Table/simpleHelpers.js +3 -8
- package/dist/components/internal/OverlayTrigger.d.ts +1 -1
- package/dist/inputs/MultiSelectField.mock.js +3 -2
- package/dist/inputs/SelectField.mock.js +3 -2
- package/package.json +1 -1
|
@@ -14,8 +14,13 @@ export interface IconButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
14
14
|
buttonRef?: RefObject<HTMLButtonElement>;
|
|
15
15
|
/** Whether to show a 16x16px version of the IconButton */
|
|
16
16
|
compact?: boolean;
|
|
17
|
+
/** Whether to display the contrast variant */
|
|
18
|
+
contrast?: boolean;
|
|
17
19
|
}
|
|
18
20
|
export declare function IconButton(props: IconButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
21
|
export declare const iconButtonStylesHover: {
|
|
20
22
|
backgroundColor: import("csstype").Property.BackgroundColor | undefined;
|
|
21
23
|
};
|
|
24
|
+
export declare const iconButtonContrastStylesHover: {
|
|
25
|
+
backgroundColor: import("csstype").Property.BackgroundColor | undefined;
|
|
26
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.iconButtonStylesHover = exports.IconButton = void 0;
|
|
3
|
+
exports.iconButtonContrastStylesHover = exports.iconButtonStylesHover = exports.IconButton = 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");
|
|
@@ -10,7 +10,7 @@ const Css_1 = require("../Css");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
12
12
|
function IconButton(props) {
|
|
13
|
-
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, } = props;
|
|
13
|
+
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, contrast = false, } = props;
|
|
14
14
|
const isDisabled = !!disabled;
|
|
15
15
|
const ariaProps = { onPress, isDisabled, autoFocus, ...menuTriggerProps };
|
|
16
16
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -26,12 +26,13 @@ function IconButton(props) {
|
|
|
26
26
|
const styles = (0, react_1.useMemo)(() => ({
|
|
27
27
|
...iconButtonStylesReset,
|
|
28
28
|
...(compact ? iconButtonCompact : iconButtonNormal),
|
|
29
|
-
...(isHovered && exports.iconButtonStylesHover),
|
|
29
|
+
...(isHovered && (contrast ? exports.iconButtonContrastStylesHover : exports.iconButtonStylesHover)),
|
|
30
30
|
...(isFocusVisible && iconButtonStylesFocus),
|
|
31
31
|
...(isDisabled && iconButtonStylesDisabled),
|
|
32
32
|
}), [isHovered, isFocusVisible, isDisabled, compact]);
|
|
33
|
+
const iconColor = contrast ? contrastIconColor : defaultIconColor;
|
|
33
34
|
const buttonAttrs = { ...testIds, ...buttonProps, ...focusProps, ...hoverProps, ref: ref, css: styles };
|
|
34
|
-
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 :
|
|
35
|
+
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 : iconColor), inc: compact ? 2 : inc }, void 0));
|
|
35
36
|
const button = typeof onPress === "string" ? ((0, utils_1.isAbsoluteUrl)(onPress) || openInNew ? ((0, jsx_runtime_1.jsx)("a", Object.assign({}, buttonAttrs, { href: onPress, className: components_1.navLink, 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));
|
|
36
37
|
// If we're disabled b/c of a non-boolean ReactNode, or the caller specified tooltip text, then show it in a tooltip
|
|
37
38
|
return (0, components_1.maybeTooltip)({
|
|
@@ -41,9 +42,12 @@ function IconButton(props) {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
exports.IconButton = IconButton;
|
|
45
|
+
const defaultIconColor = Css_1.Palette.Gray900;
|
|
46
|
+
const contrastIconColor = Css_1.Palette.White;
|
|
44
47
|
const iconButtonStylesReset = Css_1.Css.bTransparent.bsSolid.bgTransparent.cursorPointer.outline0.dif.aic.jcc.transition.$;
|
|
45
48
|
const iconButtonNormal = Css_1.Css.hPx(28).wPx(28).br8.bw2.$;
|
|
46
49
|
const iconButtonCompact = Css_1.Css.hPx(18).wPx(18).br4.bw1.$;
|
|
47
50
|
exports.iconButtonStylesHover = Css_1.Css.bgGray200.$;
|
|
51
|
+
exports.iconButtonContrastStylesHover = Css_1.Css.bgGray700.$;
|
|
48
52
|
const iconButtonStylesFocus = Css_1.Css.bLightBlue700.$;
|
|
49
53
|
const iconButtonStylesDisabled = Css_1.Css.cursorNotAllowed.$;
|
|
@@ -42,7 +42,7 @@ const users = [
|
|
|
42
42
|
{ id: "9", name: "Captain Marvel", role: "Does it all" },
|
|
43
43
|
{ id: "10", name: "Doctor Strange", role: "Doctor" },
|
|
44
44
|
];
|
|
45
|
-
const rows = [Table_1.simpleHeader, ...users.map((u) => ({ kind: "data",
|
|
45
|
+
const rows = [Table_1.simpleHeader, ...users.map((u) => ({ kind: "data", id: u.id, data: u }))];
|
|
46
46
|
const columns = [
|
|
47
47
|
{ header: () => "Name", data: ({ name }) => name },
|
|
48
48
|
{ header: () => "Role", data: ({ role }) => role },
|
|
@@ -232,7 +232,7 @@ declare type GridRowKind<R extends Kinded, P extends R["kind"]> = DiscriminateUn
|
|
|
232
232
|
export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
233
233
|
[K in R["kind"]]: string | GridCellContent | (DiscriminateUnion<R, "kind", K> extends {
|
|
234
234
|
data: infer D;
|
|
235
|
-
} ? (data: D, row: GridRowKind<R, K>, api: GridTableApi<R>) => ReactNode | GridCellContent : (row: GridRowKind<R, K>, api: GridTableApi<R>) => ReactNode | GridCellContent);
|
|
235
|
+
} ? (data: D, row: GridRowKind<R, K>, api: GridTableApi<R>) => ReactNode | GridCellContent : (data: undefined, row: GridRowKind<R, K>, api: GridTableApi<R>) => ReactNode | GridCellContent);
|
|
236
236
|
} & {
|
|
237
237
|
/**
|
|
238
238
|
* The column's width.
|
|
@@ -313,6 +313,7 @@ export declare type GridDataRow<R extends Kinded> = {
|
|
|
313
313
|
children?: GridDataRow<R>[];
|
|
314
314
|
/** Whether to pin this sort to the first/last of its parent's children. */
|
|
315
315
|
pin?: "first" | "last";
|
|
316
|
+
data: unknown;
|
|
316
317
|
} & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
|
|
317
318
|
declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
318
319
|
/** Return the content for a given column def applied to a given row. */
|
|
@@ -641,13 +641,8 @@ function applyRowFn(column, row, api) {
|
|
|
641
641
|
// Usually this is a function to apply against the row, but sometimes it's a hard-coded value, i.e. for headers
|
|
642
642
|
const maybeContent = column[row.kind];
|
|
643
643
|
if (typeof maybeContent === "function") {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
return maybeContent(row["data"], row["id"], api);
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
return maybeContent(row, api);
|
|
650
|
-
}
|
|
644
|
+
// Auto-destructure data
|
|
645
|
+
return maybeContent(row["data"], row, api);
|
|
651
646
|
}
|
|
652
647
|
else {
|
|
653
648
|
return maybeContent;
|
|
@@ -46,7 +46,7 @@ function selectColumn(columnDef) {
|
|
|
46
46
|
...columnDef,
|
|
47
47
|
};
|
|
48
48
|
return (0, index_1.newMethodMissingProxy)(base, (key) => {
|
|
49
|
-
return (row) => ({ content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id }, void 0) });
|
|
49
|
+
return (data, row) => ({ content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id }, void 0) });
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
exports.selectColumn = selectColumn;
|
|
@@ -68,7 +68,7 @@ function collapseColumn(columnDef) {
|
|
|
68
68
|
...columnDef,
|
|
69
69
|
};
|
|
70
70
|
return (0, index_1.newMethodMissingProxy)(base, (key) => {
|
|
71
|
-
return (row) => ({ content: (0, jsx_runtime_1.jsx)(CollapseToggle_1.CollapseToggle, { row: row }, void 0) });
|
|
71
|
+
return (data, row) => ({ content: (0, jsx_runtime_1.jsx)(CollapseToggle_1.CollapseToggle, { row: row }, void 0) });
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
exports.collapseColumn = collapseColumn;
|
|
@@ -8,7 +8,7 @@ export { useGridTableApi } from "./GridTableApi";
|
|
|
8
8
|
export type { GridTableApi } from "./GridTableApi";
|
|
9
9
|
export { RowState, RowStateContext } from "./RowState";
|
|
10
10
|
export * from "./SelectToggle";
|
|
11
|
-
export { simpleDataRows, simpleHeader
|
|
12
|
-
export type {
|
|
11
|
+
export { simpleDataRows, simpleHeader } from "./simpleHelpers";
|
|
12
|
+
export type { SimpleHeaderAndData } from "./simpleHelpers";
|
|
13
13
|
export { SortHeader } from "./SortHeader";
|
|
14
14
|
export { beamFixedStyle, beamFlexibleStyle, beamNestedFixedStyle, beamNestedFlexibleStyle, beamTotalsFixedStyle, beamTotalsFlexibleStyle, cardStyle, condensedStyle, defaultStyle, } from "./styles";
|
|
@@ -10,7 +10,7 @@ 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.defaultStyle = exports.condensedStyle = exports.cardStyle = exports.beamTotalsFlexibleStyle = exports.beamTotalsFixedStyle = exports.beamNestedFlexibleStyle = exports.beamNestedFixedStyle = exports.beamFlexibleStyle = exports.beamFixedStyle = exports.SortHeader = exports.
|
|
13
|
+
exports.defaultStyle = exports.condensedStyle = exports.cardStyle = exports.beamTotalsFlexibleStyle = exports.beamTotalsFixedStyle = exports.beamNestedFlexibleStyle = exports.beamNestedFixedStyle = exports.beamFlexibleStyle = exports.beamFixedStyle = exports.SortHeader = exports.simpleHeader = exports.simpleDataRows = exports.RowStateContext = exports.RowState = exports.useGridTableApi = exports.setGridTableDefaults = exports.setDefaultStyle = exports.GridTable = exports.DESC = exports.ASC = exports.GridSortContext = void 0;
|
|
14
14
|
__exportStar(require("./CollapseToggle"), exports);
|
|
15
15
|
__exportStar(require("./columns"), exports);
|
|
16
16
|
var GridSortContext_1 = require("./GridSortContext");
|
|
@@ -30,7 +30,6 @@ __exportStar(require("./SelectToggle"), exports);
|
|
|
30
30
|
var simpleHelpers_1 = require("./simpleHelpers");
|
|
31
31
|
Object.defineProperty(exports, "simpleDataRows", { enumerable: true, get: function () { return simpleHelpers_1.simpleDataRows; } });
|
|
32
32
|
Object.defineProperty(exports, "simpleHeader", { enumerable: true, get: function () { return simpleHelpers_1.simpleHeader; } });
|
|
33
|
-
Object.defineProperty(exports, "simpleRows", { enumerable: true, get: function () { return simpleHelpers_1.simpleRows; } });
|
|
34
33
|
var SortHeader_1 = require("./SortHeader");
|
|
35
34
|
Object.defineProperty(exports, "SortHeader", { enumerable: true, get: function () { return SortHeader_1.SortHeader; } });
|
|
36
35
|
var styles_1 = require("./styles");
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { GridDataRow } from "./GridTable";
|
|
2
|
-
/** A helper for making `Row` type aliases of simple/flat tables that are just header + data. */
|
|
3
|
-
export declare type SimpleHeaderAndDataOf<T> = {
|
|
4
|
-
kind: "header";
|
|
5
|
-
} | ({
|
|
6
|
-
kind: "data";
|
|
7
|
-
} & T);
|
|
8
2
|
/**
|
|
9
3
|
* A helper for making `Row` type aliases of simple/flat tables that are just header + data.
|
|
10
4
|
*
|
|
@@ -12,7 +6,7 @@ export declare type SimpleHeaderAndDataOf<T> = {
|
|
|
12
6
|
* when rows are mobx proxies and we need proxy accesses to happen within the column
|
|
13
7
|
* rendering.
|
|
14
8
|
*/
|
|
15
|
-
export declare type
|
|
9
|
+
export declare type SimpleHeaderAndData<T> = {
|
|
16
10
|
kind: "header";
|
|
17
11
|
} | {
|
|
18
12
|
kind: "data";
|
|
@@ -23,11 +17,9 @@ export declare type SimpleHeaderAndDataWith<T> = {
|
|
|
23
17
|
export declare const simpleHeader: {
|
|
24
18
|
kind: "header";
|
|
25
19
|
id: string;
|
|
20
|
+
data: {};
|
|
26
21
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}> | undefined): GridDataRow<R>[];
|
|
30
|
-
/** Like `simpleRows` but for `SimpleHeaderAndDataWith`. */
|
|
31
|
-
export declare function simpleDataRows<R extends SimpleHeaderAndDataWith<D>, D>(data?: Array<D & {
|
|
22
|
+
/** Like `simpleRows` but for `SimpleHeaderAndData`. */
|
|
23
|
+
export declare function simpleDataRows<R extends SimpleHeaderAndData<D>, D>(data?: Array<D & {
|
|
32
24
|
id: string;
|
|
33
25
|
}> | undefined): GridDataRow<R>[];
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.simpleDataRows = exports.
|
|
3
|
+
exports.simpleDataRows = exports.simpleHeader = void 0;
|
|
4
4
|
/** A const for a marker header row. */
|
|
5
|
-
exports.simpleHeader = { kind: "header", id: "header" };
|
|
6
|
-
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
return [exports.simpleHeader, ...data.map((c) => ({ kind: "data", ...c }))];
|
|
9
|
-
}
|
|
10
|
-
exports.simpleRows = simpleRows;
|
|
11
|
-
/** Like `simpleRows` but for `SimpleHeaderAndDataWith`. */
|
|
5
|
+
exports.simpleHeader = { kind: "header", id: "header", data: {} };
|
|
6
|
+
/** Like `simpleRows` but for `SimpleHeaderAndData`. */
|
|
12
7
|
function simpleDataRows(data = []) {
|
|
13
8
|
// @ts-ignore Not sure why this doesn't type-check, something esoteric with the DiscriminateUnion type
|
|
14
9
|
return [exports.simpleHeader, ...data.map((data) => ({ kind: "data", data, id: data.id }))];
|
|
@@ -5,7 +5,7 @@ import { ButtonProps } from "../Button";
|
|
|
5
5
|
import { IconButtonProps } from "../IconButton";
|
|
6
6
|
interface TextButtonTriggerProps extends Pick<ButtonProps, "label" | "variant" | "size" | "icon"> {
|
|
7
7
|
}
|
|
8
|
-
interface IconButtonTriggerProps extends Pick<IconButtonProps, "icon" | "color"> {
|
|
8
|
+
interface IconButtonTriggerProps extends Pick<IconButtonProps, "icon" | "color" | "compact" | "contrast"> {
|
|
9
9
|
}
|
|
10
10
|
export interface OverlayTriggerProps {
|
|
11
11
|
trigger: TextButtonTriggerProps | IconButtonTriggerProps;
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MultiSelectField = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const defaultTestId_1 = require("../utils/defaultTestId");
|
|
6
7
|
/** Mocks out `MultiSelectField` as a multiple `<select>` field. */
|
|
7
8
|
function MultiSelectField(props) {
|
|
8
9
|
const { getOptionValue = (o) => o.id, // if unset, assume O implements HasId
|
|
9
10
|
getOptionLabel = (o) => o.name, // if unset, assume O implements HasName
|
|
10
|
-
values, options, onSelect, readOnly = false, errorMsg, onFocus, onBlur, disabled, } = props;
|
|
11
|
-
const tid = (0, utils_1.useTestIds)(props,
|
|
11
|
+
values, options, onSelect, readOnly = false, errorMsg, onFocus, onBlur, disabled, label, } = props;
|
|
12
|
+
const tid = (0, utils_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
|
|
12
13
|
return ((0, jsx_runtime_1.jsxs)("select", Object.assign({}, tid, {
|
|
13
14
|
// We're cheating and assume the values are strings...what we should really do is either:
|
|
14
15
|
// a) use beam's valueToKey mapping to string-encode any Value, or
|
|
@@ -4,12 +4,13 @@ exports.SelectField = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
+
const defaultTestId_1 = require("../utils/defaultTestId");
|
|
7
8
|
/** Mocks out `SelectField` as a `<select>` field. */
|
|
8
9
|
function SelectField(props) {
|
|
9
10
|
const { getOptionValue = (o) => o.id, // if unset, assume O implements HasId
|
|
10
11
|
getOptionLabel = (o) => o.name, // if unset, assume O implements HasName
|
|
11
|
-
value, options: maybeOptions, onSelect, readOnly = false, errorMsg, onBlur, onFocus, disabled, disabledOptions = [], } = props;
|
|
12
|
-
const tid = (0, utils_1.useTestIds)(props,
|
|
12
|
+
value, options: maybeOptions, onSelect, readOnly = false, errorMsg, onBlur, onFocus, disabled, disabledOptions = [], label, } = props;
|
|
13
|
+
const tid = (0, utils_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
|
|
13
14
|
const [options, setOptions] = (0, react_1.useState)(Array.isArray(maybeOptions) ? maybeOptions : maybeOptions.initial);
|
|
14
15
|
const currentOption = options.find((o) => getOptionValue(o) === value) || options[0];
|
|
15
16
|
(0, react_1.useEffect)(() => {
|