@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.d.cts
CHANGED
|
@@ -9533,6 +9533,8 @@ type GridTableLayoutProps<F extends Record<string, unknown>, R extends Kinded, X
|
|
|
9533
9533
|
/** Shows "N Rows Selected · Clear" before the columns selector; Clear deselects every row. */
|
|
9534
9534
|
selectionSummary?: boolean;
|
|
9535
9535
|
hideEditColumns?: boolean;
|
|
9536
|
+
/** When set, columns that share a name use one Edit Columns switch. */
|
|
9537
|
+
shareColumnVisibility?: boolean;
|
|
9536
9538
|
totalCount?: number;
|
|
9537
9539
|
/** When true, shows a view toggle button and renders the table with `as="card"` when in card view. */
|
|
9538
9540
|
withCardView?: boolean;
|
|
@@ -11030,6 +11032,8 @@ interface TriggerNoticeProps extends Omit<SnackbarNoticeProps, "id" | "onClose">
|
|
|
11030
11032
|
type EditColumnsButtonProps<R extends Kinded> = {
|
|
11031
11033
|
columns: GridColumn<R>[];
|
|
11032
11034
|
api: GridTableApi<R>;
|
|
11035
|
+
/** When set, columns that share a name use one Edit Columns switch. */
|
|
11036
|
+
shareColumnVisibility?: boolean;
|
|
11033
11037
|
defaultOpen?: boolean;
|
|
11034
11038
|
} & Pick<OverlayTriggerProps, "placement" | "disabled" | "tooltip">;
|
|
11035
11039
|
declare function EditColumnsButton<R extends Kinded>(props: EditColumnsButtonProps<R>): React$1.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -9533,6 +9533,8 @@ type GridTableLayoutProps<F extends Record<string, unknown>, R extends Kinded, X
|
|
|
9533
9533
|
/** Shows "N Rows Selected · Clear" before the columns selector; Clear deselects every row. */
|
|
9534
9534
|
selectionSummary?: boolean;
|
|
9535
9535
|
hideEditColumns?: boolean;
|
|
9536
|
+
/** When set, columns that share a name use one Edit Columns switch. */
|
|
9537
|
+
shareColumnVisibility?: boolean;
|
|
9536
9538
|
totalCount?: number;
|
|
9537
9539
|
/** When true, shows a view toggle button and renders the table with `as="card"` when in card view. */
|
|
9538
9540
|
withCardView?: boolean;
|
|
@@ -11030,6 +11032,8 @@ interface TriggerNoticeProps extends Omit<SnackbarNoticeProps, "id" | "onClose">
|
|
|
11030
11032
|
type EditColumnsButtonProps<R extends Kinded> = {
|
|
11031
11033
|
columns: GridColumn<R>[];
|
|
11032
11034
|
api: GridTableApi<R>;
|
|
11035
|
+
/** When set, columns that share a name use one Edit Columns switch. */
|
|
11036
|
+
shareColumnVisibility?: boolean;
|
|
11033
11037
|
defaultOpen?: boolean;
|
|
11034
11038
|
} & Pick<OverlayTriggerProps, "placement" | "disabled" | "tooltip">;
|
|
11035
11039
|
declare function EditColumnsButton<R extends Kinded>(props: EditColumnsButtonProps<R>): React$1.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -25139,7 +25139,8 @@ function EditColumnsButton(props) {
|
|
|
25139
25139
|
defaultOpen,
|
|
25140
25140
|
disabled,
|
|
25141
25141
|
columns,
|
|
25142
|
-
api
|
|
25142
|
+
api,
|
|
25143
|
+
shareColumnVisibility = false
|
|
25143
25144
|
} = props;
|
|
25144
25145
|
const state = useMenuTriggerState4({
|
|
25145
25146
|
defaultOpen
|
|
@@ -25154,26 +25155,13 @@ function EditColumnsButton(props) {
|
|
|
25154
25155
|
const {
|
|
25155
25156
|
sm
|
|
25156
25157
|
} = useBreakpoint();
|
|
25157
|
-
const options = useMemo42(() => columns
|
|
25158
|
-
if (!column2.name || column2.name.length === 0 || !column2.id || column2.id.length === 0) {
|
|
25159
|
-
console.warn("Column is missing 'name' and/or 'id' property required by the Edit Columns button", column2);
|
|
25160
|
-
return false;
|
|
25161
|
-
}
|
|
25162
|
-
return true;
|
|
25163
|
-
}).map((column2) => ({
|
|
25164
|
-
label: column2.name,
|
|
25165
|
-
value: column2.id,
|
|
25166
|
-
tooltip: column2.tooltip
|
|
25167
|
-
})), [columns]);
|
|
25158
|
+
const options = useMemo42(() => buildColumnOptions(columns, shareColumnVisibility), [columns, shareColumnVisibility]);
|
|
25168
25159
|
const selectedValues = useComputed(() => api.getVisibleColumnIds(), [api]);
|
|
25169
25160
|
const setSelectedValues = useCallback27((ids) => {
|
|
25170
25161
|
api.resetColumnWidths();
|
|
25171
25162
|
api.setVisibleColumns(columns.filter((column2) => column2.canHide ? ids.includes(column2.id) : true).map((c) => c.id));
|
|
25172
25163
|
}, [columns, api]);
|
|
25173
|
-
const hasHiddenColumn = useMemo42(() =>
|
|
25174
|
-
const selectableOptionValues = options.map((option) => option.value);
|
|
25175
|
-
return selectableOptionValues.some((option) => !selectedValues.includes(option));
|
|
25176
|
-
}, [options, selectedValues]);
|
|
25164
|
+
const hasHiddenColumn = useMemo42(() => options.some((option) => option.ids.some((id) => !selectedValues.includes(id))), [options, selectedValues]);
|
|
25177
25165
|
return /* @__PURE__ */ jsx179(OverlayTrigger, { ...props, trigger: sm ? {
|
|
25178
25166
|
icon: hasHiddenColumn ? "columnsBadged" : "columns",
|
|
25179
25167
|
variant: "outline"
|
|
@@ -25201,7 +25189,7 @@ function EditColumnsButton(props) {
|
|
|
25201
25189
|
/* @__PURE__ */ jsx179("span", { className: "fw4 fz_14px lh_20px mw0", children: option.label }),
|
|
25202
25190
|
option.tooltip ? /* @__PURE__ */ jsx179(ColumnTooltipIcon, { ...tid[`tooltip_${option.value}`], tooltip: closeMenuOnClickTooltip(option.tooltip, state.close), color: "--b-text-link-default" /* TextLinkDefault */, label: option.label }) : null
|
|
25203
25191
|
] }),
|
|
25204
|
-
/* @__PURE__ */ jsx179(Switch, { compact: true, selected: selectedValues.includes(
|
|
25192
|
+
/* @__PURE__ */ jsx179(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}`] })
|
|
25205
25193
|
] }, option.value)) }),
|
|
25206
25194
|
/* @__PURE__ */ jsx179("div", { ...trussProps105({
|
|
25207
25195
|
display: "df",
|
|
@@ -25218,6 +25206,54 @@ function EditColumnsButton(props) {
|
|
|
25218
25206
|
}), children: /* @__PURE__ */ jsx179(Button, { variant: "tertiary", label: "Reset Column Widths", onClick: () => api.resetColumnWidths() }) })
|
|
25219
25207
|
] }) });
|
|
25220
25208
|
}
|
|
25209
|
+
function buildColumnOptions(columns, shareColumnVisibility) {
|
|
25210
|
+
const hideable = columns.filter((column2) => {
|
|
25211
|
+
if (!column2.canHide) return false;
|
|
25212
|
+
if (!column2.name || column2.name.length === 0 || !column2.id || column2.id.length === 0) {
|
|
25213
|
+
console.warn("Column is missing 'name' and/or 'id' property required by the Edit Columns button", column2);
|
|
25214
|
+
return false;
|
|
25215
|
+
}
|
|
25216
|
+
return true;
|
|
25217
|
+
});
|
|
25218
|
+
if (!shareColumnVisibility) {
|
|
25219
|
+
return hideable.map((column2) => ({
|
|
25220
|
+
label: column2.name,
|
|
25221
|
+
value: column2.id,
|
|
25222
|
+
ids: [column2.id],
|
|
25223
|
+
tooltip: column2.tooltip
|
|
25224
|
+
}));
|
|
25225
|
+
}
|
|
25226
|
+
const byLabel = /* @__PURE__ */ new Map();
|
|
25227
|
+
const warnedLabels = /* @__PURE__ */ new Set();
|
|
25228
|
+
for (const column2 of hideable) {
|
|
25229
|
+
const label = leafColumnName(column2);
|
|
25230
|
+
const existing = byLabel.get(label);
|
|
25231
|
+
if (!existing) {
|
|
25232
|
+
byLabel.set(label, {
|
|
25233
|
+
label,
|
|
25234
|
+
value: column2.id,
|
|
25235
|
+
ids: [column2.id],
|
|
25236
|
+
tooltip: column2.tooltip
|
|
25237
|
+
});
|
|
25238
|
+
continue;
|
|
25239
|
+
}
|
|
25240
|
+
existing.ids.push(column2.id);
|
|
25241
|
+
if (existing.tooltip !== column2.tooltip && !warnedLabels.has(label)) {
|
|
25242
|
+
warnedLabels.add(label);
|
|
25243
|
+
console.warn(`Edit Columns columns labeled "${label}" have different tooltips. Using the first.`);
|
|
25244
|
+
}
|
|
25245
|
+
}
|
|
25246
|
+
return [...byLabel.values()];
|
|
25247
|
+
}
|
|
25248
|
+
function leafColumnName(column2) {
|
|
25249
|
+
const {
|
|
25250
|
+
name,
|
|
25251
|
+
groupLabel
|
|
25252
|
+
} = column2;
|
|
25253
|
+
const prefix = groupLabel ? `${groupLabel}: ` : void 0;
|
|
25254
|
+
if (name && prefix && name.startsWith(prefix)) return name.slice(prefix.length);
|
|
25255
|
+
return name;
|
|
25256
|
+
}
|
|
25221
25257
|
function closeMenuOnClickTooltip(tooltip, closeMenu) {
|
|
25222
25258
|
if (typeof tooltip !== "function") return tooltip;
|
|
25223
25259
|
return () => {
|
|
@@ -25442,6 +25478,7 @@ function GridTableLayoutActionsComponent(props) {
|
|
|
25442
25478
|
searchProps,
|
|
25443
25479
|
hasHideableColumns,
|
|
25444
25480
|
columns,
|
|
25481
|
+
shareColumnVisibility,
|
|
25445
25482
|
api,
|
|
25446
25483
|
withCardView,
|
|
25447
25484
|
view,
|
|
@@ -25535,7 +25572,7 @@ function GridTableLayoutActionsComponent(props) {
|
|
|
25535
25572
|
] }),
|
|
25536
25573
|
(hasHideableColumns || withCardView || !!actions?.length || selectionSummary) && /* @__PURE__ */ jsxs96("div", { className: "df aic g_12px", children: [
|
|
25537
25574
|
selectionSummary && api && /* @__PURE__ */ jsx184(SelectionSummaryAction, { api, numberOnly: sm }),
|
|
25538
|
-
hasHideableColumns && view === "list" && columns && api && /* @__PURE__ */ jsx184(EditColumnsButton, { columns, api, tooltip: "Display columns" }),
|
|
25575
|
+
hasHideableColumns && view === "list" && columns && api && /* @__PURE__ */ jsx184(EditColumnsButton, { columns, api, shareColumnVisibility, tooltip: "Display columns" }),
|
|
25539
25576
|
withCardView && view !== void 0 && setView && /* @__PURE__ */ jsx184(ViewToggleButton, { view, onChange: setView }),
|
|
25540
25577
|
!!actions?.length && /* @__PURE__ */ jsx184(HeaderActions, { actions, ...testId.actions })
|
|
25541
25578
|
] })
|
|
@@ -26414,6 +26451,7 @@ function GridTableLayoutComponent(props) {
|
|
|
26414
26451
|
actions,
|
|
26415
26452
|
selectionSummary = false,
|
|
26416
26453
|
hideEditColumns = false,
|
|
26454
|
+
shareColumnVisibility = false,
|
|
26417
26455
|
withCardView,
|
|
26418
26456
|
defaultView = "list",
|
|
26419
26457
|
emptyFallback: layoutEmptyFallback,
|
|
@@ -26468,6 +26506,7 @@ function GridTableLayoutComponent(props) {
|
|
|
26468
26506
|
searchProps: filterSearchProps,
|
|
26469
26507
|
hasHideableColumns,
|
|
26470
26508
|
columns,
|
|
26509
|
+
shareColumnVisibility,
|
|
26471
26510
|
api,
|
|
26472
26511
|
withCardView,
|
|
26473
26512
|
view,
|