@homebound/beam 4.40.1 → 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 +57 -18
- 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 +57 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25630,7 +25630,8 @@ function EditColumnsButton(props) {
|
|
|
25630
25630
|
defaultOpen,
|
|
25631
25631
|
disabled,
|
|
25632
25632
|
columns,
|
|
25633
|
-
api
|
|
25633
|
+
api,
|
|
25634
|
+
shareColumnVisibility = false
|
|
25634
25635
|
} = props;
|
|
25635
25636
|
const state = (0, import_react_stately17.useMenuTriggerState)({
|
|
25636
25637
|
defaultOpen
|
|
@@ -25645,26 +25646,13 @@ function EditColumnsButton(props) {
|
|
|
25645
25646
|
const {
|
|
25646
25647
|
sm
|
|
25647
25648
|
} = useBreakpoint();
|
|
25648
|
-
const options = (0, import_react117.useMemo)(() => columns
|
|
25649
|
-
if (!column2.name || column2.name.length === 0 || !column2.id || column2.id.length === 0) {
|
|
25650
|
-
console.warn("Column is missing 'name' and/or 'id' property required by the Edit Columns button", column2);
|
|
25651
|
-
return false;
|
|
25652
|
-
}
|
|
25653
|
-
return true;
|
|
25654
|
-
}).map((column2) => ({
|
|
25655
|
-
label: column2.name,
|
|
25656
|
-
value: column2.id,
|
|
25657
|
-
tooltip: column2.tooltip
|
|
25658
|
-
})), [columns]);
|
|
25649
|
+
const options = (0, import_react117.useMemo)(() => buildColumnOptions(columns, shareColumnVisibility), [columns, shareColumnVisibility]);
|
|
25659
25650
|
const selectedValues = useComputed(() => api.getVisibleColumnIds(), [api]);
|
|
25660
25651
|
const setSelectedValues = (0, import_react117.useCallback)((ids) => {
|
|
25661
25652
|
api.resetColumnWidths();
|
|
25662
25653
|
api.setVisibleColumns(columns.filter((column2) => column2.canHide ? ids.includes(column2.id) : true).map((c) => c.id));
|
|
25663
25654
|
}, [columns, api]);
|
|
25664
|
-
const hasHiddenColumn = (0, import_react117.useMemo)(() =>
|
|
25665
|
-
const selectableOptionValues = options.map((option) => option.value);
|
|
25666
|
-
return selectableOptionValues.some((option) => !selectedValues.includes(option));
|
|
25667
|
-
}, [options, selectedValues]);
|
|
25655
|
+
const hasHiddenColumn = (0, import_react117.useMemo)(() => options.some((option) => option.ids.some((id) => !selectedValues.includes(id))), [options, selectedValues]);
|
|
25668
25656
|
return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(OverlayTrigger, { ...props, trigger: sm ? {
|
|
25669
25657
|
icon: hasHiddenColumn ? "columnsBadged" : "columns",
|
|
25670
25658
|
variant: "outline"
|
|
@@ -25692,7 +25680,7 @@ function EditColumnsButton(props) {
|
|
|
25692
25680
|
/* @__PURE__ */ (0, import_jsx_runtime179.jsx)("span", { className: "fw4 fz_14px lh_20px mw0", children: option.label }),
|
|
25693
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
|
|
25694
25682
|
] }),
|
|
25695
|
-
/* @__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}`] })
|
|
25696
25684
|
] }, option.value)) }),
|
|
25697
25685
|
/* @__PURE__ */ (0, import_jsx_runtime179.jsx)("div", { ...(0, import_runtime119.trussProps)({
|
|
25698
25686
|
display: "df",
|
|
@@ -25709,6 +25697,54 @@ function EditColumnsButton(props) {
|
|
|
25709
25697
|
}), children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(Button, { variant: "tertiary", label: "Reset Column Widths", onClick: () => api.resetColumnWidths() }) })
|
|
25710
25698
|
] }) });
|
|
25711
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
|
+
}
|
|
25712
25748
|
function closeMenuOnClickTooltip(tooltip, closeMenu) {
|
|
25713
25749
|
if (typeof tooltip !== "function") return tooltip;
|
|
25714
25750
|
return () => {
|
|
@@ -25933,6 +25969,7 @@ function GridTableLayoutActionsComponent(props) {
|
|
|
25933
25969
|
searchProps,
|
|
25934
25970
|
hasHideableColumns,
|
|
25935
25971
|
columns,
|
|
25972
|
+
shareColumnVisibility,
|
|
25936
25973
|
api,
|
|
25937
25974
|
withCardView,
|
|
25938
25975
|
view,
|
|
@@ -26026,7 +26063,7 @@ function GridTableLayoutActionsComponent(props) {
|
|
|
26026
26063
|
] }),
|
|
26027
26064
|
(hasHideableColumns || withCardView || !!actions?.length || selectionSummary) && /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)("div", { className: "df aic g_12px", children: [
|
|
26028
26065
|
selectionSummary && api && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(SelectionSummaryAction, { api, numberOnly: sm }),
|
|
26029
|
-
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" }),
|
|
26030
26067
|
withCardView && view !== void 0 && setView && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(ViewToggleButton, { view, onChange: setView }),
|
|
26031
26068
|
!!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(HeaderActions, { actions, ...testId.actions })
|
|
26032
26069
|
] })
|
|
@@ -26905,6 +26942,7 @@ function GridTableLayoutComponent(props) {
|
|
|
26905
26942
|
actions,
|
|
26906
26943
|
selectionSummary = false,
|
|
26907
26944
|
hideEditColumns = false,
|
|
26945
|
+
shareColumnVisibility = false,
|
|
26908
26946
|
withCardView,
|
|
26909
26947
|
defaultView = "list",
|
|
26910
26948
|
emptyFallback: layoutEmptyFallback,
|
|
@@ -26959,6 +26997,7 @@ function GridTableLayoutComponent(props) {
|
|
|
26959
26997
|
searchProps: filterSearchProps,
|
|
26960
26998
|
hasHideableColumns,
|
|
26961
26999
|
columns,
|
|
27000
|
+
shareColumnVisibility,
|
|
26962
27001
|
api,
|
|
26963
27002
|
withCardView,
|
|
26964
27003
|
view,
|