@homebound/beam 4.40.0 → 4.41.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/index.cjs +79 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +79 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6780,7 +6780,7 @@ var ColumnState = class {
|
|
|
6780
6780
|
constructor(states, storage, column2) {
|
|
6781
6781
|
this.states = states;
|
|
6782
6782
|
this.column = column2;
|
|
6783
|
-
this.visible = storage.wasVisible(column2.id) ??
|
|
6783
|
+
this.visible = !column2.canHide || (storage.wasVisible(column2.id) ?? !(column2.initHidden ?? true));
|
|
6784
6784
|
if (this.visible && (storage.wasExpanded(column2.id) ?? column2.initExpanded)) {
|
|
6785
6785
|
this.expanded = true;
|
|
6786
6786
|
this.doExpand();
|
|
@@ -6791,10 +6791,17 @@ var ColumnState = class {
|
|
|
6791
6791
|
children = void 0;
|
|
6792
6792
|
visible = true;
|
|
6793
6793
|
expanded = false;
|
|
6794
|
+
/**
|
|
6795
|
+
* Whether this column is shown. We check `canHide` here too b/c when `props.columns` changes,
|
|
6796
|
+
* `addColumn` can replace a hidden column's definition with one that can't be hidden.
|
|
6797
|
+
*/
|
|
6798
|
+
get isVisible() {
|
|
6799
|
+
return this.visible || !this.column.canHide;
|
|
6800
|
+
}
|
|
6794
6801
|
setVisible(visible) {
|
|
6795
|
-
const wasVisible = this.
|
|
6796
|
-
this.visible = visible;
|
|
6797
|
-
if (!wasVisible && visible && this.column.initExpanded && this.children === void 0) {
|
|
6802
|
+
const wasVisible = this.isVisible;
|
|
6803
|
+
this.visible = visible || !this.column.canHide;
|
|
6804
|
+
if (!wasVisible && this.visible && this.column.initExpanded && this.children === void 0) {
|
|
6798
6805
|
this.expanded = true;
|
|
6799
6806
|
this.doExpand();
|
|
6800
6807
|
}
|
|
@@ -6818,9 +6825,13 @@ var ColumnState = class {
|
|
|
6818
6825
|
this.children = expandColumns.map((ec) => this.states.addColumn(ec));
|
|
6819
6826
|
}
|
|
6820
6827
|
}
|
|
6828
|
+
/** Returns this column and all of its loaded children, whether visible and expanded or not. */
|
|
6829
|
+
get selfAndChildren() {
|
|
6830
|
+
return [this, ...(this.children ?? []).flatMap((c) => c.selfAndChildren)];
|
|
6831
|
+
}
|
|
6821
6832
|
/** Returns this column, if visible, and its children, if expanded. */
|
|
6822
6833
|
get maybeSelfAndChildren() {
|
|
6823
|
-
if (!this.
|
|
6834
|
+
if (!this.isVisible) {
|
|
6824
6835
|
return [];
|
|
6825
6836
|
} else if (this.expanded && this.children) {
|
|
6826
6837
|
return [this, ...this.children.flatMap((c) => c.maybeSelfAndChildren)];
|
|
@@ -8070,9 +8081,13 @@ var ColumnStates = class {
|
|
|
8070
8081
|
allVisibleColumns(showIn) {
|
|
8071
8082
|
return this.columns.flatMap((cs) => cs.maybeSelfAndChildren).filter((cs) => !cs.column.showIn || cs.column.showIn === showIn).filter((cs) => showIn === "csv" ? isContentColumn(cs.column) : true);
|
|
8072
8083
|
}
|
|
8084
|
+
/**
|
|
8085
|
+
* Shows the current columns in `ids` and hides the others. Columns that can't be hidden, like layout gutters, stay shown.
|
|
8086
|
+
* Columns not currently in the table keep their visibility, so a column that's temporarily removed comes back as it was.
|
|
8087
|
+
*/
|
|
8073
8088
|
setVisibleColumns(ids) {
|
|
8074
|
-
for (const cs of this.
|
|
8075
|
-
cs.setVisible(
|
|
8089
|
+
for (const cs of this.columns.flatMap((c) => c.selfAndChildren)) {
|
|
8090
|
+
cs.setVisible(ids.includes(cs.column.id));
|
|
8076
8091
|
}
|
|
8077
8092
|
}
|
|
8078
8093
|
loadExpanded(storageKey) {
|
|
@@ -25615,7 +25630,8 @@ function EditColumnsButton(props) {
|
|
|
25615
25630
|
defaultOpen,
|
|
25616
25631
|
disabled,
|
|
25617
25632
|
columns,
|
|
25618
|
-
api
|
|
25633
|
+
api,
|
|
25634
|
+
shareColumnVisibility = false
|
|
25619
25635
|
} = props;
|
|
25620
25636
|
const state = (0, import_react_stately17.useMenuTriggerState)({
|
|
25621
25637
|
defaultOpen
|
|
@@ -25630,26 +25646,13 @@ function EditColumnsButton(props) {
|
|
|
25630
25646
|
const {
|
|
25631
25647
|
sm
|
|
25632
25648
|
} = useBreakpoint();
|
|
25633
|
-
const options = (0, import_react117.useMemo)(() => columns
|
|
25634
|
-
if (!column2.name || column2.name.length === 0 || !column2.id || column2.id.length === 0) {
|
|
25635
|
-
console.warn("Column is missing 'name' and/or 'id' property required by the Edit Columns button", column2);
|
|
25636
|
-
return false;
|
|
25637
|
-
}
|
|
25638
|
-
return true;
|
|
25639
|
-
}).map((column2) => ({
|
|
25640
|
-
label: column2.name,
|
|
25641
|
-
value: column2.id,
|
|
25642
|
-
tooltip: column2.tooltip
|
|
25643
|
-
})), [columns]);
|
|
25649
|
+
const options = (0, import_react117.useMemo)(() => buildColumnOptions(columns, shareColumnVisibility), [columns, shareColumnVisibility]);
|
|
25644
25650
|
const selectedValues = useComputed(() => api.getVisibleColumnIds(), [api]);
|
|
25645
25651
|
const setSelectedValues = (0, import_react117.useCallback)((ids) => {
|
|
25646
25652
|
api.resetColumnWidths();
|
|
25647
25653
|
api.setVisibleColumns(columns.filter((column2) => column2.canHide ? ids.includes(column2.id) : true).map((c) => c.id));
|
|
25648
25654
|
}, [columns, api]);
|
|
25649
|
-
const hasHiddenColumn = (0, import_react117.useMemo)(() =>
|
|
25650
|
-
const selectableOptionValues = options.map((option) => option.value);
|
|
25651
|
-
return selectableOptionValues.some((option) => !selectedValues.includes(option));
|
|
25652
|
-
}, [options, selectedValues]);
|
|
25655
|
+
const hasHiddenColumn = (0, import_react117.useMemo)(() => options.some((option) => option.ids.some((id) => !selectedValues.includes(id))), [options, selectedValues]);
|
|
25653
25656
|
return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(OverlayTrigger, { ...props, trigger: sm ? {
|
|
25654
25657
|
icon: hasHiddenColumn ? "columnsBadged" : "columns",
|
|
25655
25658
|
variant: "outline"
|
|
@@ -25677,7 +25680,7 @@ function EditColumnsButton(props) {
|
|
|
25677
25680
|
/* @__PURE__ */ (0, import_jsx_runtime179.jsx)("span", { className: "fw4 fz_14px lh_20px mw0", children: option.label }),
|
|
25678
25681
|
option.tooltip ? /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(ColumnTooltipIcon, { ...tid[`tooltip_${option.value}`], tooltip: closeMenuOnClickTooltip(option.tooltip, state.close), color: "--b-text-link-default" /* TextLinkDefault */, label: option.label }) : null
|
|
25679
25682
|
] }),
|
|
25680
|
-
/* @__PURE__ */ (0, import_jsx_runtime179.jsx)(Switch, { compact: true, selected: selectedValues.includes(
|
|
25683
|
+
/* @__PURE__ */ (0, import_jsx_runtime179.jsx)(Switch, { compact: true, selected: option.ids.every((id) => selectedValues.includes(id)), onChange: (value) => setSelectedValues(value ? [...selectedValues, ...option.ids] : selectedValues.filter((id) => !option.ids.includes(id))), labelStyle: "hidden", label: option.label, ...tid[`option${option.value}`] })
|
|
25681
25684
|
] }, option.value)) }),
|
|
25682
25685
|
/* @__PURE__ */ (0, import_jsx_runtime179.jsx)("div", { ...(0, import_runtime119.trussProps)({
|
|
25683
25686
|
display: "df",
|
|
@@ -25694,6 +25697,54 @@ function EditColumnsButton(props) {
|
|
|
25694
25697
|
}), children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(Button, { variant: "tertiary", label: "Reset Column Widths", onClick: () => api.resetColumnWidths() }) })
|
|
25695
25698
|
] }) });
|
|
25696
25699
|
}
|
|
25700
|
+
function buildColumnOptions(columns, shareColumnVisibility) {
|
|
25701
|
+
const hideable = columns.filter((column2) => {
|
|
25702
|
+
if (!column2.canHide) return false;
|
|
25703
|
+
if (!column2.name || column2.name.length === 0 || !column2.id || column2.id.length === 0) {
|
|
25704
|
+
console.warn("Column is missing 'name' and/or 'id' property required by the Edit Columns button", column2);
|
|
25705
|
+
return false;
|
|
25706
|
+
}
|
|
25707
|
+
return true;
|
|
25708
|
+
});
|
|
25709
|
+
if (!shareColumnVisibility) {
|
|
25710
|
+
return hideable.map((column2) => ({
|
|
25711
|
+
label: column2.name,
|
|
25712
|
+
value: column2.id,
|
|
25713
|
+
ids: [column2.id],
|
|
25714
|
+
tooltip: column2.tooltip
|
|
25715
|
+
}));
|
|
25716
|
+
}
|
|
25717
|
+
const byLabel = /* @__PURE__ */ new Map();
|
|
25718
|
+
const warnedLabels = /* @__PURE__ */ new Set();
|
|
25719
|
+
for (const column2 of hideable) {
|
|
25720
|
+
const label = leafColumnName(column2);
|
|
25721
|
+
const existing = byLabel.get(label);
|
|
25722
|
+
if (!existing) {
|
|
25723
|
+
byLabel.set(label, {
|
|
25724
|
+
label,
|
|
25725
|
+
value: column2.id,
|
|
25726
|
+
ids: [column2.id],
|
|
25727
|
+
tooltip: column2.tooltip
|
|
25728
|
+
});
|
|
25729
|
+
continue;
|
|
25730
|
+
}
|
|
25731
|
+
existing.ids.push(column2.id);
|
|
25732
|
+
if (existing.tooltip !== column2.tooltip && !warnedLabels.has(label)) {
|
|
25733
|
+
warnedLabels.add(label);
|
|
25734
|
+
console.warn(`Edit Columns columns labeled "${label}" have different tooltips. Using the first.`);
|
|
25735
|
+
}
|
|
25736
|
+
}
|
|
25737
|
+
return [...byLabel.values()];
|
|
25738
|
+
}
|
|
25739
|
+
function leafColumnName(column2) {
|
|
25740
|
+
const {
|
|
25741
|
+
name,
|
|
25742
|
+
groupLabel
|
|
25743
|
+
} = column2;
|
|
25744
|
+
const prefix = groupLabel ? `${groupLabel}: ` : void 0;
|
|
25745
|
+
if (name && prefix && name.startsWith(prefix)) return name.slice(prefix.length);
|
|
25746
|
+
return name;
|
|
25747
|
+
}
|
|
25697
25748
|
function closeMenuOnClickTooltip(tooltip, closeMenu) {
|
|
25698
25749
|
if (typeof tooltip !== "function") return tooltip;
|
|
25699
25750
|
return () => {
|
|
@@ -25918,6 +25969,7 @@ function GridTableLayoutActionsComponent(props) {
|
|
|
25918
25969
|
searchProps,
|
|
25919
25970
|
hasHideableColumns,
|
|
25920
25971
|
columns,
|
|
25972
|
+
shareColumnVisibility,
|
|
25921
25973
|
api,
|
|
25922
25974
|
withCardView,
|
|
25923
25975
|
view,
|
|
@@ -26011,7 +26063,7 @@ function GridTableLayoutActionsComponent(props) {
|
|
|
26011
26063
|
] }),
|
|
26012
26064
|
(hasHideableColumns || withCardView || !!actions?.length || selectionSummary) && /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)("div", { className: "df aic g_12px", children: [
|
|
26013
26065
|
selectionSummary && api && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(SelectionSummaryAction, { api, numberOnly: sm }),
|
|
26014
|
-
hasHideableColumns && view === "list" && columns && api && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(EditColumnsButton, { columns, api, tooltip: "Display columns" }),
|
|
26066
|
+
hasHideableColumns && view === "list" && columns && api && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(EditColumnsButton, { columns, api, shareColumnVisibility, tooltip: "Display columns" }),
|
|
26015
26067
|
withCardView && view !== void 0 && setView && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(ViewToggleButton, { view, onChange: setView }),
|
|
26016
26068
|
!!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(HeaderActions, { actions, ...testId.actions })
|
|
26017
26069
|
] })
|
|
@@ -26890,6 +26942,7 @@ function GridTableLayoutComponent(props) {
|
|
|
26890
26942
|
actions,
|
|
26891
26943
|
selectionSummary = false,
|
|
26892
26944
|
hideEditColumns = false,
|
|
26945
|
+
shareColumnVisibility = false,
|
|
26893
26946
|
withCardView,
|
|
26894
26947
|
defaultView = "list",
|
|
26895
26948
|
emptyFallback: layoutEmptyFallback,
|
|
@@ -26944,6 +26997,7 @@ function GridTableLayoutComponent(props) {
|
|
|
26944
26997
|
searchProps: filterSearchProps,
|
|
26945
26998
|
hasHideableColumns,
|
|
26946
26999
|
columns,
|
|
27000
|
+
shareColumnVisibility,
|
|
26947
27001
|
api,
|
|
26948
27002
|
withCardView,
|
|
26949
27003
|
view,
|