@homebound/beam 2.122.1 → 2.123.2
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/Table/CollapseToggle.d.ts +2 -2
- package/dist/components/Table/CollapseToggle.js +3 -3
- package/dist/components/Table/GridTable.d.ts +14 -3
- package/dist/components/Table/GridTable.js +12 -7
- package/dist/components/Table/columns.js +7 -3
- package/dist/components/Table/sortRows.js +2 -2
- package/dist/components/Table/styles.js +3 -3
- package/dist/components/Tooltip.js +6 -1
- package/dist/inputs/ChipSelectField.js +1 -1
- package/dist/inputs/TextFieldBase.js +2 -0
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GridDataRow } from "..";
|
|
2
|
-
export interface GridTableCollapseToggleProps {
|
|
1
|
+
import { GridDataRow, IconButtonProps } from "..";
|
|
2
|
+
export interface GridTableCollapseToggleProps extends Pick<IconButtonProps, "compact"> {
|
|
3
3
|
row: GridDataRow<any>;
|
|
4
4
|
}
|
|
5
5
|
/** Provides a chevron icons to collapse/un-collapse for parent/child tables. */
|
|
@@ -7,16 +7,16 @@ const components_1 = require("..");
|
|
|
7
7
|
const hooks_1 = require("../../hooks");
|
|
8
8
|
/** Provides a chevron icons to collapse/un-collapse for parent/child tables. */
|
|
9
9
|
function CollapseToggle(props) {
|
|
10
|
-
const { row } = props;
|
|
10
|
+
const { row, compact } = props;
|
|
11
11
|
const { rowState } = (0, react_1.useContext)(components_1.RowStateContext);
|
|
12
12
|
const isCollapsed = (0, hooks_1.useComputed)(() => rowState.isCollapsed(row.id), [rowState]);
|
|
13
13
|
const iconKey = isCollapsed ? "chevronRight" : "chevronDown";
|
|
14
14
|
const headerIconKey = isCollapsed ? "chevronsRight" : "chevronsDown";
|
|
15
15
|
// If we're not a header, only render a toggle if we have child rows to actually collapse
|
|
16
16
|
const isHeader = row.kind === "header";
|
|
17
|
-
if (!isHeader && (!
|
|
17
|
+
if (!isHeader && (!row.children || row.children.length === 0)) {
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
|
-
return (0, jsx_runtime_1.jsx)(components_1.IconButton, { onClick: () => rowState.toggleCollapsed(row.id), icon: isHeader ? headerIconKey : iconKey }, void 0);
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(components_1.IconButton, { onClick: () => rowState.toggleCollapsed(row.id), icon: isHeader ? headerIconKey : iconKey, compact: compact }, void 0));
|
|
21
21
|
}
|
|
22
22
|
exports.CollapseToggle = CollapseToggle;
|
|
@@ -53,7 +53,8 @@ export interface GridStyle {
|
|
|
53
53
|
minWidthPx?: number;
|
|
54
54
|
/** Css to apply at each level of a parent/child nested table. */
|
|
55
55
|
levels?: Record<number, {
|
|
56
|
-
cellCss
|
|
56
|
+
cellCss?: Properties;
|
|
57
|
+
firstContentColumn?: Properties;
|
|
57
58
|
}>;
|
|
58
59
|
/** Allows for customization of the background color used to denote an "active" row */
|
|
59
60
|
activeBgColor?: Palette;
|
|
@@ -232,7 +233,15 @@ declare type GridRowKind<R extends Kinded, P extends R["kind"]> = DiscriminateUn
|
|
|
232
233
|
export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
233
234
|
[K in R["kind"]]: string | GridCellContent | (DiscriminateUnion<R, "kind", K> extends {
|
|
234
235
|
data: infer D;
|
|
235
|
-
} ? (data: D,
|
|
236
|
+
} ? (data: D, opts: {
|
|
237
|
+
row: GridRowKind<R, K>;
|
|
238
|
+
api: GridTableApi<R>;
|
|
239
|
+
level: number;
|
|
240
|
+
}) => ReactNode | GridCellContent : (data: undefined, opts: {
|
|
241
|
+
row: GridRowKind<R, K>;
|
|
242
|
+
api: GridTableApi<R>;
|
|
243
|
+
level: number;
|
|
244
|
+
}) => ReactNode | GridCellContent);
|
|
236
245
|
} & {
|
|
237
246
|
/**
|
|
238
247
|
* The column's width.
|
|
@@ -253,6 +262,8 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
|
253
262
|
sticky?: "left" | "right";
|
|
254
263
|
/** Prevent column from supporting RowStyle.onClick/rowLink in order to avoid nested interactivity. Defaults to true */
|
|
255
264
|
wrapAction?: false;
|
|
265
|
+
/** Used as a signal to defer adding the 'indent' styling */
|
|
266
|
+
isAction?: true;
|
|
256
267
|
};
|
|
257
268
|
export declare const nonKindGridColumnKeys: string[];
|
|
258
269
|
/** Allows rendering a specific cell. */
|
|
@@ -317,6 +328,6 @@ export declare type GridDataRow<R extends Kinded> = {
|
|
|
317
328
|
} & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
|
|
318
329
|
declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
319
330
|
/** Return the content for a given column def applied to a given row. */
|
|
320
|
-
export declare function applyRowFn<R extends Kinded>(column: GridColumn<R>, row: GridDataRow<R>, api: GridTableApi<R
|
|
331
|
+
export declare function applyRowFn<R extends Kinded>(column: GridColumn<R>, row: GridDataRow<R>, api: GridTableApi<R>, level: number): ReactNode | GridCellContent;
|
|
321
332
|
export declare function matchesFilter(maybeContent: ReactNode | GridCellContent, filter: string): boolean;
|
|
322
333
|
export {};
|
|
@@ -125,7 +125,7 @@ function GridTable(props) {
|
|
|
125
125
|
const matches = row.kind === "header" ||
|
|
126
126
|
filters.length === 0 ||
|
|
127
127
|
!!row.pin ||
|
|
128
|
-
filters.every((f) => columns.map((c) => applyRowFn(c, row, api)).some((maybeContent) => matchesFilter(maybeContent, f)));
|
|
128
|
+
filters.every((f) => columns.map((c) => applyRowFn(c, row, api, 0)).some((maybeContent) => matchesFilter(maybeContent, f)));
|
|
129
129
|
// If the row matches, add it in
|
|
130
130
|
if (matches) {
|
|
131
131
|
return acc.concat([[row, (_b = (_a = row.children) === null || _a === void 0 ? void 0 : _a.reduce(filterRows, [])) !== null && _b !== void 0 ? _b : []]]);
|
|
@@ -491,9 +491,12 @@ function GridRow(props) {
|
|
|
491
491
|
...(0, nestedCards_1.getNestedCardStyles)(row, openCardStyles, style, isActive),
|
|
492
492
|
};
|
|
493
493
|
let currentColspan = 1;
|
|
494
|
+
let firstContentColumnStylesApplied = false;
|
|
494
495
|
const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, getCount(row.id), { children: columns.map((column, columnIndex) => {
|
|
495
|
-
var _a, _b, _c, _d, _e;
|
|
496
|
-
const { wrapAction = true } = column;
|
|
496
|
+
var _a, _b, _c, _d, _e, _f;
|
|
497
|
+
const { wrapAction = true, isAction = false } = column;
|
|
498
|
+
const applyFirstContentColumnStyles = !isAction && !firstContentColumnStylesApplied;
|
|
499
|
+
firstContentColumnStylesApplied || (firstContentColumnStylesApplied = applyFirstContentColumnStyles);
|
|
497
500
|
if (column.mw) {
|
|
498
501
|
// Validate the column's minWidth definition if set.
|
|
499
502
|
if (!column.mw.endsWith("px") && !column.mw.endsWith("%")) {
|
|
@@ -505,7 +508,7 @@ function GridRow(props) {
|
|
|
505
508
|
currentColspan -= 1;
|
|
506
509
|
return null;
|
|
507
510
|
}
|
|
508
|
-
const maybeContent = applyRowFn(column, row, api);
|
|
511
|
+
const maybeContent = applyRowFn(column, row, api, level);
|
|
509
512
|
currentColspan = isGridCellContent(maybeContent) ? (_a = maybeContent.colspan) !== null && _a !== void 0 ? _a : 1 : 1;
|
|
510
513
|
const canSortColumn = (sortOn === "client" && column.clientSideSort !== false) ||
|
|
511
514
|
(sortOn === "server" && !!column.serverSideSortKey);
|
|
@@ -560,11 +563,13 @@ function GridRow(props) {
|
|
|
560
563
|
...(isHeader && style.headerCellCss),
|
|
561
564
|
// Or level-specific styling
|
|
562
565
|
...(!isHeader && !!style.levels && ((_d = style.levels[level]) === null || _d === void 0 ? void 0 : _d.cellCss)),
|
|
566
|
+
// Level specific styling for the first content column
|
|
567
|
+
...(applyFirstContentColumnStyles && !!style.levels && ((_e = style.levels[level]) === null || _e === void 0 ? void 0 : _e.firstContentColumn)),
|
|
563
568
|
// The specific cell's css (if any from GridCellContent)
|
|
564
569
|
...rowStyleCellCss,
|
|
565
570
|
// Apply active row styling for non-nested card styles.
|
|
566
571
|
...(style.nestedCards === undefined && isActive
|
|
567
|
-
? Css_1.Css.bgColor((
|
|
572
|
+
? Css_1.Css.bgColor((_f = style.activeBgColor) !== null && _f !== void 0 ? _f : Css_1.Palette.LightBlue50).$
|
|
568
573
|
: {}),
|
|
569
574
|
// Add any cell specific style overrides
|
|
570
575
|
...(isGridCellContent(maybeContent) && maybeContent.typeScale ? Css_1.Css[maybeContent.typeScale].$ : {}),
|
|
@@ -638,12 +643,12 @@ function isContentEmpty(content) {
|
|
|
638
643
|
return emptyValues.includes(content);
|
|
639
644
|
}
|
|
640
645
|
/** Return the content for a given column def applied to a given row. */
|
|
641
|
-
function applyRowFn(column, row, api) {
|
|
646
|
+
function applyRowFn(column, row, api, level) {
|
|
642
647
|
// Usually this is a function to apply against the row, but sometimes it's a hard-coded value, i.e. for headers
|
|
643
648
|
const maybeContent = column[row.kind];
|
|
644
649
|
if (typeof maybeContent === "function") {
|
|
645
650
|
// Auto-destructure data
|
|
646
|
-
return maybeContent(row["data"], row, api);
|
|
651
|
+
return maybeContent(row["data"], { row: row, api, level });
|
|
647
652
|
}
|
|
648
653
|
else {
|
|
649
654
|
return maybeContent;
|
|
@@ -24,7 +24,7 @@ function numericColumn(columnDef) {
|
|
|
24
24
|
exports.numericColumn = numericColumn;
|
|
25
25
|
/** Provides default styling for a GridColumn representing an Action. */
|
|
26
26
|
function actionColumn(columnDef) {
|
|
27
|
-
return { clientSideSort: false, ...columnDef, align: "center" };
|
|
27
|
+
return { clientSideSort: false, ...columnDef, align: "center", isAction: true };
|
|
28
28
|
}
|
|
29
29
|
exports.actionColumn = actionColumn;
|
|
30
30
|
/**
|
|
@@ -42,11 +42,12 @@ function selectColumn(columnDef) {
|
|
|
42
42
|
// Defining `w: 48px` to accommodate for the `16px` wide checkbox and `16px` of padding on either side.
|
|
43
43
|
w: "48px",
|
|
44
44
|
wrapAction: false,
|
|
45
|
+
isAction: true,
|
|
45
46
|
// Use any of the user's per-row kind methods if they have them.
|
|
46
47
|
...columnDef,
|
|
47
48
|
};
|
|
48
49
|
return (0, index_1.newMethodMissingProxy)(base, (key) => {
|
|
49
|
-
return (data, row) => ({ content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id }, void 0) });
|
|
50
|
+
return (data, { row }) => ({ content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id }, void 0) });
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
exports.selectColumn = selectColumn;
|
|
@@ -65,10 +66,13 @@ function collapseColumn(columnDef) {
|
|
|
65
66
|
// Defining `w: 38px` based on the designs
|
|
66
67
|
w: "38px",
|
|
67
68
|
wrapAction: false,
|
|
69
|
+
isAction: true,
|
|
68
70
|
...columnDef,
|
|
69
71
|
};
|
|
70
72
|
return (0, index_1.newMethodMissingProxy)(base, (key) => {
|
|
71
|
-
return (data,
|
|
73
|
+
return (data, { row, level }) => ({
|
|
74
|
+
content: (0, jsx_runtime_1.jsx)(CollapseToggle_1.CollapseToggle, { row: row, compact: level > 0 }, void 0),
|
|
75
|
+
});
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
exports.collapseColumn = collapseColumn;
|
|
@@ -21,8 +21,8 @@ function sortBatch(columns, batch, sortState) {
|
|
|
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, {}));
|
|
25
|
-
const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}));
|
|
24
|
+
const v1 = sortValue((0, GridTable_1.applyRowFn)(column, a, {}, 0));
|
|
25
|
+
const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}, 0));
|
|
26
26
|
const v1e = v1 === null || v1 === undefined;
|
|
27
27
|
const v2e = v2 === null || v2 === undefined;
|
|
28
28
|
if (a.pin || b.pin) {
|
|
@@ -42,7 +42,7 @@ exports.cardStyle = {
|
|
|
42
42
|
// Once completely rolled out across all tables in Blueprint, this will change to be the `defaultStyle`.
|
|
43
43
|
exports.beamFixedStyle = {
|
|
44
44
|
headerCellCss: Css_1.Css.gray700.xsEm.bgGray200.aic.nowrap.pxPx(12).hPx(40).$,
|
|
45
|
-
cellCss: Css_1.Css.gray900.xs.bgWhite.aic.nowrap.pxPx(12).hPx(36).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.
|
|
45
|
+
cellCss: Css_1.Css.gray900.xs.bgWhite.aic.nowrap.pxPx(12).hPx(36).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
|
|
46
46
|
emptyCell: "-",
|
|
47
47
|
presentationSettings: { borderless: true, typeScale: "xs", wrap: false },
|
|
48
48
|
firstRowMessageCss: Css_1.Css.tc.py3.$,
|
|
@@ -57,7 +57,7 @@ exports.beamGroupRowStyle = Css_1.Css.xsEm
|
|
|
57
57
|
exports.beamTotalsRowStyle = Css_1.Css.gray700.smEm.hPx(40).mb1.bgWhite.boxShadow("none").$;
|
|
58
58
|
exports.beamNestedFixedStyle = {
|
|
59
59
|
...exports.beamFixedStyle,
|
|
60
|
-
levels: { 0: { cellCss: exports.beamGroupRowStyle } },
|
|
60
|
+
levels: { 0: { cellCss: exports.beamGroupRowStyle }, 2: { firstContentColumn: Css_1.Css.tiny.pl3.$ } },
|
|
61
61
|
};
|
|
62
62
|
exports.beamTotalsFixedStyle = {
|
|
63
63
|
...exports.beamFixedStyle,
|
|
@@ -70,7 +70,7 @@ exports.beamFlexibleStyle = {
|
|
|
70
70
|
};
|
|
71
71
|
exports.beamNestedFlexibleStyle = {
|
|
72
72
|
...exports.beamFlexibleStyle,
|
|
73
|
-
levels: { 0: { cellCss: exports.beamGroupRowStyle } },
|
|
73
|
+
levels: { 0: { cellCss: exports.beamGroupRowStyle }, 2: { firstContentColumn: Css_1.Css.tiny.pl3.$ } },
|
|
74
74
|
};
|
|
75
75
|
exports.beamTotalsFlexibleStyle = {
|
|
76
76
|
...exports.beamFlexibleStyle,
|
|
@@ -35,7 +35,12 @@ function Tooltip(props) {
|
|
|
35
35
|
const { triggerProps, tooltipProps: _tooltipProps } = (0, react_aria_1.useTooltipTrigger)({ isDisabled: disabled }, state, triggerRef);
|
|
36
36
|
const { tooltipProps } = (0, react_aria_1.useTooltip)(_tooltipProps, state);
|
|
37
37
|
const tid = (0, utils_1.useTestIds)(props, "tooltip");
|
|
38
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ ref: triggerRef }, triggerProps, (!state.isOpen && typeof title === "string" ? { title } : {}), tid, {
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ ref: triggerRef }, triggerProps, (!state.isOpen && typeof title === "string" ? { title } : {}), tid, {
|
|
39
|
+
// Adding `draggable` as a hack to allow focus to continue through this element and into its children.
|
|
40
|
+
// This is due to some code in React-Aria that prevents default due ot mobile browser inconsistencies,
|
|
41
|
+
// and the only way they don't prevent default is if the element is draggable.
|
|
42
|
+
// See https://github.com/adobe/react-spectrum/discussions/3058 for discussion related to this issue.
|
|
43
|
+
draggable: true, onDragStart: (e) => e.preventDefault() }, { children: children }), void 0), state.isOpen && ((0, jsx_runtime_1.jsx)(Popper, Object.assign({}, (0, react_aria_1.mergeProps)(_tooltipProps, tooltipProps), { triggerRef: triggerRef, content: title, placement: placement }), void 0))] }, void 0));
|
|
39
44
|
}
|
|
40
45
|
exports.Tooltip = Tooltip;
|
|
41
46
|
function Popper({ triggerRef, content, placement = "auto" }) {
|
|
@@ -100,11 +100,11 @@ function ChipSelectField(props) {
|
|
|
100
100
|
items: listData.items,
|
|
101
101
|
children: selectChildren,
|
|
102
102
|
autoFocus: true,
|
|
103
|
+
disallowEmptySelection: false,
|
|
103
104
|
};
|
|
104
105
|
const state = (0, react_stately_1.useSelectState)({
|
|
105
106
|
...selectHookProps,
|
|
106
107
|
selectedKey: (0, Value_1.valueToKey)(value),
|
|
107
|
-
disallowEmptySelection: false,
|
|
108
108
|
onSelectionChange: (key) => {
|
|
109
109
|
if (key === createNewOpt.id) {
|
|
110
110
|
setShowInput(true);
|
|
@@ -50,6 +50,8 @@ function TextFieldBase(props) {
|
|
|
50
50
|
.if(compact)
|
|
51
51
|
.mhPx(compactFieldHeight - maybeSmaller).$,
|
|
52
52
|
...Css_1.Css.gray900.if(contrast).white.$,
|
|
53
|
+
// Make read-only fields vertically line up with editable fields in tables
|
|
54
|
+
...(borderless ? Css_1.Css.px1.$ : {}),
|
|
53
55
|
},
|
|
54
56
|
input: {
|
|
55
57
|
...Css_1.Css.w100.mw0.outline0.fg1.if(multiline).br4.$,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homebound/beam",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.123.2",
|
|
4
4
|
"author": "Homebound",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@homebound/form-state": "2.13.0",
|
|
36
36
|
"@internationalized/number": "^3.0.3",
|
|
37
|
-
"@react-aria/utils": "^3.
|
|
37
|
+
"@react-aria/utils": "^3.11.3",
|
|
38
38
|
"@react-hook/resize-observer": "^1.2.2",
|
|
39
39
|
"change-case": "^4.1.2",
|
|
40
40
|
"date-fns": "^2.21.3",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"fast-deep-equal": "^3.1.3",
|
|
43
43
|
"framer-motion": "^4.1.11",
|
|
44
44
|
"memoize-one": "^5.2.1",
|
|
45
|
-
"react-aria": "^3.
|
|
45
|
+
"react-aria": "^3.14.1",
|
|
46
46
|
"react-day-picker": "^7.4.10",
|
|
47
47
|
"react-popper": "^2.2.5",
|
|
48
48
|
"react-router": "^5.2.0",
|
|
49
49
|
"react-router-dom": "^5.2.0",
|
|
50
|
-
"react-stately": "^3.
|
|
50
|
+
"react-stately": "^3.12.2",
|
|
51
51
|
"react-virtuoso": "^2.4.0",
|
|
52
52
|
"tributejs": "^5.1.3",
|
|
53
53
|
"trix": "^1.3.1",
|