@homebound/beam 2.148.1 → 2.149.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/Table/GridTable.d.ts +3 -0
- package/dist/components/Table/GridTableApi.js +2 -7
- package/dist/components/Table/SelectToggle.d.ts +6 -3
- package/dist/components/Table/SelectToggle.js +3 -3
- package/dist/components/Table/columns.js +3 -1
- package/dist/inputs/CheckboxBase.js +5 -3
- package/package.json +1 -1
|
@@ -222,6 +222,7 @@ export declare type DiscriminateUnion<T, K extends keyof T, V extends T[K]> = T
|
|
|
222
222
|
declare type GridRowKind<R extends Kinded, P extends R["kind"]> = DiscriminateUnion<R, "kind", P> & {
|
|
223
223
|
id: string;
|
|
224
224
|
children: GridDataRow<R>[];
|
|
225
|
+
selectable?: false;
|
|
225
226
|
};
|
|
226
227
|
/**
|
|
227
228
|
* Defines how a single column will render each given row `kind` in `R`.
|
|
@@ -333,6 +334,8 @@ export declare type GridDataRow<R extends Kinded> = {
|
|
|
333
334
|
data: unknown;
|
|
334
335
|
/** Whether to have the row collapsed (children not visible) on initial load. This will be ignore in subsequent re-renders of the table */
|
|
335
336
|
initCollapsed?: boolean;
|
|
337
|
+
/** Whether row can be selected */
|
|
338
|
+
selectable?: false;
|
|
336
339
|
} & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
|
|
337
340
|
declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
338
341
|
/** Return the content for a given column def applied to a given row. */
|
|
@@ -39,19 +39,14 @@ class GridTableApiImpl {
|
|
|
39
39
|
this.virtuosoRef.current && this.virtuosoRef.current.scrollToIndex(index);
|
|
40
40
|
}
|
|
41
41
|
getSelectedRowIds(kind) {
|
|
42
|
-
|
|
43
|
-
return this.rowState.selectedIds;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return this.getSelectedRows(kind).map((row) => row.id);
|
|
47
|
-
}
|
|
42
|
+
return this.getSelectedRows(kind).map((row) => row.id);
|
|
48
43
|
}
|
|
49
44
|
// The any is not great, but getting the overload to handle the optional kind is annoying
|
|
50
45
|
getSelectedRows(kind) {
|
|
51
46
|
const ids = this.rowState.selectedIds;
|
|
52
47
|
const selected = [];
|
|
53
48
|
(0, visitor_1.visit)(this.rowState.rows, (row) => {
|
|
54
|
-
if (ids.includes(row.id) && (!kind || row.kind === kind)) {
|
|
49
|
+
if (row.selectable !== false && ids.includes(row.id) && (!kind || row.kind === kind)) {
|
|
55
50
|
selected.push(row);
|
|
56
51
|
}
|
|
57
52
|
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function SelectToggle({ id }: {
|
|
1
|
+
interface SelectToggleProps {
|
|
3
2
|
id: string;
|
|
4
|
-
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/** Provides a checkbox to show/drive this row's selected state. */
|
|
6
|
+
export declare function SelectToggle({ id, disabled }: SelectToggleProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -7,12 +7,12 @@ const RowState_1 = require("./RowState");
|
|
|
7
7
|
const index_1 = require("../../hooks/index");
|
|
8
8
|
const index_2 = require("../../inputs/index");
|
|
9
9
|
/** Provides a checkbox to show/drive this row's selected state. */
|
|
10
|
-
function SelectToggle({ id }) {
|
|
10
|
+
function SelectToggle({ id, disabled }) {
|
|
11
11
|
const { rowState } = (0, react_1.useContext)(RowState_1.RowStateContext);
|
|
12
12
|
const state = (0, index_1.useComputed)(() => rowState.getSelected(id), [rowState]);
|
|
13
13
|
const selected = state === "checked" ? true : state === "unchecked" ? false : "indeterminate";
|
|
14
|
-
return ((0, jsx_runtime_1.jsx)(index_2.Checkbox, {
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(index_2.Checkbox, { checkboxOnly: true, disabled: disabled, label: "Select", onChange: (selected) => {
|
|
15
15
|
rowState.selectRow(id, selected);
|
|
16
|
-
} }, void 0));
|
|
16
|
+
}, selected: selected }, void 0));
|
|
17
17
|
}
|
|
18
18
|
exports.SelectToggle = SelectToggle;
|
|
@@ -47,7 +47,9 @@ function selectColumn(columnDef) {
|
|
|
47
47
|
...columnDef,
|
|
48
48
|
};
|
|
49
49
|
return (0, index_1.newMethodMissingProxy)(base, (key) => {
|
|
50
|
-
return (data, { row }) => ({
|
|
50
|
+
return (data, { row }) => ({
|
|
51
|
+
content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id, disabled: row.selectable === false }, void 0),
|
|
52
|
+
});
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
exports.selectColumn = selectColumn;
|
|
@@ -25,9 +25,10 @@ function CheckboxBase(props) {
|
|
|
25
25
|
.maxw((0, Css_1.px)(344))
|
|
26
26
|
.if(isDisabled).cursorNotAllowed.$, "aria-label": label }, { children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, (0, react_aria_1.mergeProps)(inputProps, focusProps), tid), void 0) }, void 0), (0, jsx_runtime_1.jsx)("span", Object.assign({}, hoverProps, { css: {
|
|
27
27
|
...baseStyles,
|
|
28
|
-
...((isSelected || isIndeterminate) && filledBoxStyles),
|
|
29
|
-
...((isSelected || isIndeterminate) && isHovered && filledBoxHoverStyles),
|
|
28
|
+
...(((isSelected && !isDisabled) || isIndeterminate) && filledBoxStyles),
|
|
29
|
+
...(((isSelected && !isDisabled) || isIndeterminate) && isHovered && filledBoxHoverStyles),
|
|
30
30
|
...(isDisabled && disabledBoxStyles),
|
|
31
|
+
...(isDisabled && isSelected && disabledSelectedBoxStyles),
|
|
31
32
|
...(isFocusVisible && focusRingStyles),
|
|
32
33
|
...(isHovered && hoverBorderStyles),
|
|
33
34
|
...markStyles,
|
|
@@ -40,7 +41,8 @@ exports.CheckboxBase = CheckboxBase;
|
|
|
40
41
|
const baseStyles = Css_1.Css.hPx(16).mw((0, Css_1.px)(16)).relative.ba.bGray300.br4.bgWhite.transition.$;
|
|
41
42
|
const filledBoxStyles = Css_1.Css.bLightBlue700.bgLightBlue700.$;
|
|
42
43
|
const filledBoxHoverStyles = Css_1.Css.bgLightBlue900.$;
|
|
43
|
-
const disabledBoxStyles = Css_1.Css.
|
|
44
|
+
const disabledBoxStyles = Css_1.Css.bgGray50.bGray100.$;
|
|
45
|
+
const disabledSelectedBoxStyles = Css_1.Css.bgGray400.bGray400.$;
|
|
44
46
|
const disabledColor = Css_1.Css.gray300.$;
|
|
45
47
|
const focusRingStyles = Css_1.Css.bshFocus.$;
|
|
46
48
|
const hoverBorderStyles = Css_1.Css.bLightBlue900.$;
|