@homebound/beam 2.189.0 → 2.190.1
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 +1 -1
- package/dist/components/Table/components/EditColumnsButton.js +4 -4
- package/dist/components/Table/components/Row.js +2 -2
- package/dist/components/Table/hooks/useColumns.js +7 -7
- package/dist/components/Table/types.d.ts +2 -2
- package/dist/inputs/NumberField.d.ts +3 -0
- package/dist/inputs/NumberField.js +12 -9
- package/package.json +1 -1
|
@@ -101,7 +101,7 @@ export interface GridTableProps<R extends Kinded, S, X> {
|
|
|
101
101
|
activeRowId?: string;
|
|
102
102
|
/**
|
|
103
103
|
* Defines which cell in the table should be provided with an "active" styling.
|
|
104
|
-
* Expected format is `${row.kind}_${row.id}_${column.
|
|
104
|
+
* Expected format is `${row.kind}_${row.id}_${column.id}`.
|
|
105
105
|
*/
|
|
106
106
|
activeCellId?: string;
|
|
107
107
|
}
|
|
@@ -21,17 +21,17 @@ function EditColumnsButton(props) {
|
|
|
21
21
|
// Only include options that can be hidden and have the `name` property defined.
|
|
22
22
|
if (!column.canHide)
|
|
23
23
|
return acc;
|
|
24
|
-
if (!column.
|
|
24
|
+
if (!column.id || column.id.length === 0) {
|
|
25
25
|
console.warn("Column is missing 'name' property required by the Edit Columns button", column);
|
|
26
26
|
return acc;
|
|
27
27
|
}
|
|
28
28
|
// Add current column as an option
|
|
29
|
-
return { ...acc, options: acc.options.concat({ label: column.
|
|
29
|
+
return { ...acc, options: acc.options.concat({ label: column.id, value: column.id }) };
|
|
30
30
|
}, { options: [] });
|
|
31
31
|
}, [allColumns]);
|
|
32
|
-
const selectedValues = selectedColumns.map((column) => column.
|
|
32
|
+
const selectedValues = selectedColumns.map((column) => column.id);
|
|
33
33
|
const setSelectedValues = (0, react_1.useCallback)((values) => {
|
|
34
|
-
setSelectedColumns(allColumns.filter((column) => (column.canHide ? values.includes(column.
|
|
34
|
+
setSelectedColumns(allColumns.filter((column) => (column.canHide ? values.includes(column.id) : true)));
|
|
35
35
|
}, [allColumns, setSelectedColumns]);
|
|
36
36
|
return ((0, jsx_runtime_1.jsx)(OverlayTrigger_1.OverlayTrigger, Object.assign({}, props, { menuTriggerProps: menuTriggerProps, state: state, buttonRef: buttonRef }, tid, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
37
37
|
...Css_1.Css.bgWhite.py5.px3.maxwPx(380).bshBasic.$,
|
|
@@ -100,8 +100,8 @@ function RowImpl(props) {
|
|
|
100
100
|
: {}),
|
|
101
101
|
}
|
|
102
102
|
: {};
|
|
103
|
-
const cellId = `${row.kind}_${row.id}_${column.
|
|
104
|
-
const applyCellHighlight = cellHighlight && !!column.
|
|
103
|
+
const cellId = `${row.kind}_${row.id}_${column.id}`;
|
|
104
|
+
const applyCellHighlight = cellHighlight && !!column.id && !isHeader && !isTotals;
|
|
105
105
|
const isCellActive = rowState.activeCellId === cellId;
|
|
106
106
|
// Note that it seems expensive to calc a per-cell class name/CSS-in-JS output,
|
|
107
107
|
// vs. setting global/table-wide CSS like `style.cellCss` on the root grid div with
|
|
@@ -6,27 +6,27 @@ const react_1 = require("react");
|
|
|
6
6
|
const useSessionStorage_1 = require("../../../hooks/useSessionStorage");
|
|
7
7
|
function useColumns(tableColumns, maybeStorageKey) {
|
|
8
8
|
const { selectedColumns, hideColumns } = tableColumns.reduce((acc, column) => {
|
|
9
|
-
// Only include options that can be hidden and have the `
|
|
10
|
-
if (!column.
|
|
11
|
-
console.warn("Column is missing '
|
|
9
|
+
// Only include options that can be hidden and have the `id` property defined.
|
|
10
|
+
if (!column.id || column.id.length === 0) {
|
|
11
|
+
console.warn("Column is missing 'id' property required by the Edit Columns button", column);
|
|
12
12
|
return acc;
|
|
13
13
|
}
|
|
14
14
|
// Add hide-able columns
|
|
15
15
|
if (column.canHide) {
|
|
16
|
-
acc.hideColumns.push(column.
|
|
16
|
+
acc.hideColumns.push(column.id);
|
|
17
17
|
}
|
|
18
18
|
// Add selected columns
|
|
19
19
|
if (!column.canHide || (column.canHide && column.initVisible)) {
|
|
20
|
-
acc.selectedColumns.push(column.
|
|
20
|
+
acc.selectedColumns.push(column.id);
|
|
21
21
|
}
|
|
22
22
|
return { ...acc };
|
|
23
23
|
}, { selectedColumns: [], hideColumns: [] });
|
|
24
24
|
const storageKey = maybeStorageKey !== null && maybeStorageKey !== void 0 ? maybeStorageKey : (0, change_case_1.camelCase)(hideColumns.map((c) => c).join(""));
|
|
25
25
|
const [storageNames, setStorageNames] = (0, useSessionStorage_1.useSessionStorage)(storageKey, selectedColumns);
|
|
26
|
-
const storageColumns = storageNames && storageNames.map((sc) => tableColumns.find((column) => column.
|
|
26
|
+
const storageColumns = storageNames && storageNames.map((sc) => tableColumns.find((column) => column.id === sc));
|
|
27
27
|
const [columns, setColumns] = (0, react_1.useState)(storageColumns);
|
|
28
28
|
(0, react_1.useEffect)(() => {
|
|
29
|
-
setStorageNames(columns.map((column) => column.
|
|
29
|
+
setStorageNames(columns.map((column) => column.id));
|
|
30
30
|
}, [columns]);
|
|
31
31
|
return [columns, setColumns];
|
|
32
32
|
}
|
|
@@ -64,8 +64,8 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
|
64
64
|
wrapAction?: false;
|
|
65
65
|
/** Used as a signal to defer adding the 'indent' styling */
|
|
66
66
|
isAction?: true;
|
|
67
|
-
/** Column
|
|
68
|
-
|
|
67
|
+
/** Column id that will be used to generate an unique identifier for every row cell */
|
|
68
|
+
id?: string;
|
|
69
69
|
/** Flag that will allow to know which columns are hide-able */
|
|
70
70
|
canHide?: boolean;
|
|
71
71
|
/** Flag that will allow to know which hide-able columns are visible on initial load */
|
|
@@ -28,6 +28,9 @@ export interface NumberFieldProps {
|
|
|
28
28
|
onEnter?: VoidFunction;
|
|
29
29
|
placeholder?: string;
|
|
30
30
|
errorInTooltip?: true;
|
|
31
|
+
/** Whether to show comma separation for group numbers.
|
|
32
|
+
* @default true */
|
|
33
|
+
useGrouping?: boolean;
|
|
31
34
|
}
|
|
32
35
|
export declare function NumberField(props: NumberFieldProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
33
36
|
export declare function formatValue(value: number, factor: number, numFractionDigits: number | undefined, numIntegerDigits: number | undefined): number | undefined;
|
|
@@ -15,7 +15,7 @@ function NumberField(props) {
|
|
|
15
15
|
// Determine default alignment based on presentation context
|
|
16
16
|
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
17
17
|
const alignment = (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.numberAlignment) === "right" ? Css_1.Css.tr.jcfe.$ : Css_1.Css.tl.jcfs.$;
|
|
18
|
-
const { disabled, required, readOnly, type, label, onBlur, onFocus, errorMsg, helperText, value, onChange, xss, displayDirection = false, numFractionDigits = type === "dollars" ? 2 : undefined, truncate = false, onEnter, numberFormatOptions, numIntegerDigits, ...otherProps } = props;
|
|
18
|
+
const { disabled, required, readOnly, type, label, onBlur, onFocus, errorMsg, helperText, value, onChange, xss, displayDirection = false, numFractionDigits = type === "dollars" ? 2 : undefined, truncate = false, onEnter, numberFormatOptions, numIntegerDigits, useGrouping = true, ...otherProps } = props;
|
|
19
19
|
const isDisabled = !!disabled;
|
|
20
20
|
const isReadOnly = !!readOnly;
|
|
21
21
|
const factor = type === "percent" || type === "cents" ? 100 : type === "basisPoints" ? 10000 : 1;
|
|
@@ -23,7 +23,9 @@ function NumberField(props) {
|
|
|
23
23
|
const defaultFormatOptions = (0, react_1.useMemo)(() => ({
|
|
24
24
|
[truncate ? "maximumFractionDigits" : "minimumFractionDigits"]: numFractionDigits,
|
|
25
25
|
...(numIntegerDigits !== undefined && { minimumIntegerDigits: numIntegerDigits }),
|
|
26
|
-
|
|
26
|
+
useGrouping,
|
|
27
|
+
signDisplay,
|
|
28
|
+
}), [truncate, numIntegerDigits, useGrouping, signDisplay]);
|
|
27
29
|
const { locale } = (0, react_aria_1.useLocale)();
|
|
28
30
|
// If formatOptions isn't memo'd, a useEffect in useNumberStateField will cause jank,
|
|
29
31
|
// see: https://github.com/adobe/react-spectrum/issues/1893.
|
|
@@ -31,17 +33,18 @@ function NumberField(props) {
|
|
|
31
33
|
if (numberFormatOptions !== undefined) {
|
|
32
34
|
return numberFormatOptions;
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
? { style: "percent"
|
|
36
|
+
const typeFormat = type === "percent"
|
|
37
|
+
? { style: "percent" }
|
|
36
38
|
: type === "basisPoints"
|
|
37
|
-
? { style: "percent", minimumFractionDigits: 2
|
|
39
|
+
? { style: "percent", minimumFractionDigits: 2 }
|
|
38
40
|
: type === "cents"
|
|
39
|
-
? { style: "currency", currency: "USD", minimumFractionDigits: 2
|
|
41
|
+
? { style: "currency", currency: "USD", minimumFractionDigits: 2 }
|
|
40
42
|
: type === "dollars"
|
|
41
|
-
? { style: "currency", currency: "USD", minimumFractionDigits: numFractionDigits !== null && numFractionDigits !== void 0 ? numFractionDigits : 2
|
|
43
|
+
? { style: "currency", currency: "USD", minimumFractionDigits: numFractionDigits !== null && numFractionDigits !== void 0 ? numFractionDigits : 2 }
|
|
42
44
|
: type === "days"
|
|
43
|
-
? { style: "unit", unit: "day", unitDisplay: "long", maximumFractionDigits: 0
|
|
44
|
-
:
|
|
45
|
+
? { style: "unit", unit: "day", unitDisplay: "long", maximumFractionDigits: 0 }
|
|
46
|
+
: {};
|
|
47
|
+
return { ...defaultFormatOptions, ...typeFormat };
|
|
45
48
|
}, [type, numberFormatOptions]);
|
|
46
49
|
const numberParser = (0, react_1.useMemo)(() => new number_1.NumberParser(locale, formatOptions), [locale, formatOptions]);
|
|
47
50
|
const valueRef = (0, react_1.useRef)({ wip: false });
|