@homebound/beam 2.257.0 → 2.259.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.
|
@@ -197,7 +197,7 @@ function GridTable(props) {
|
|
|
197
197
|
return [headerRows, visibleDataRows, totalsRows, expandableHeaderRows, filteredRowIds];
|
|
198
198
|
}, [as, api, filter, maybeSorted, columns, style, rowStyles, sortOn, columnSizes, collapsedIds, getCount]);
|
|
199
199
|
// Once our header rows are created we can organize them in expected order.
|
|
200
|
-
const tableHeadRows =
|
|
200
|
+
const tableHeadRows = expandableHeaderRows.concat(headerRows).concat(totalsRows);
|
|
201
201
|
let tooManyClientSideRows = false;
|
|
202
202
|
if (filterMaxRows && visibleDataRows.length > filterMaxRows) {
|
|
203
203
|
tooManyClientSideRows = true;
|
|
@@ -68,7 +68,7 @@ export interface GridStyleDef {
|
|
|
68
68
|
vAlign?: "top" | "center" | "bottom";
|
|
69
69
|
}
|
|
70
70
|
export declare const getTableStyles: (props?: GridStyleDef) => GridStyle;
|
|
71
|
-
export declare const totalsRowHeight =
|
|
71
|
+
export declare const totalsRowHeight = 40;
|
|
72
72
|
export declare const expandableHeaderRowHeight = 40;
|
|
73
73
|
/** Defines row-specific styling for each given row `kind` in `R` */
|
|
74
74
|
export type RowStyles<R extends Kinded> = {
|
|
@@ -38,7 +38,7 @@ function memoizedTableStyles() {
|
|
|
38
38
|
...Css_1.Css.gray700.xsMd.bgGray200.aic.pxPx(12).whiteSpace("unset").hPx(40).$,
|
|
39
39
|
...(allWhite && Css_1.Css.bgWhite.$),
|
|
40
40
|
},
|
|
41
|
-
totalsCellCss: Css_1.Css.bgWhite.gray700.
|
|
41
|
+
totalsCellCss: Css_1.Css.bgWhite.gray700.bgGray100.xsMd.hPx(exports.totalsRowHeight).pPx(12).$,
|
|
42
42
|
expandableHeaderCss: Css_1.Css.bgWhite.gray900.xsMd.wsNormal
|
|
43
43
|
.hPx(exports.expandableHeaderRowHeight)
|
|
44
44
|
.pxPx(12)
|
|
@@ -66,7 +66,7 @@ function memoizedTableStyles() {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
exports.getTableStyles = memoizedTableStyles();
|
|
69
|
-
exports.totalsRowHeight =
|
|
69
|
+
exports.totalsRowHeight = 40;
|
|
70
70
|
exports.expandableHeaderRowHeight = 40;
|
|
71
71
|
/** Our original table look & feel/style. */
|
|
72
72
|
exports.defaultStyle = {
|
|
@@ -35,6 +35,7 @@ export interface NumberFieldProps extends Pick<PresentationFieldProps, "labelSty
|
|
|
35
35
|
borderless?: boolean;
|
|
36
36
|
sizeToContent?: boolean;
|
|
37
37
|
alwaysShowHelperText?: boolean;
|
|
38
|
+
positiveOnly?: boolean;
|
|
38
39
|
}
|
|
39
40
|
export declare function NumberField(props: NumberFieldProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
40
|
-
export declare function formatValue(value: number, factor: number, numFractionDigits: number | undefined, numIntegerDigits: number | undefined): number | undefined;
|
|
41
|
+
export declare function formatValue(value: number, factor: number, numFractionDigits: number | undefined, numIntegerDigits: number | undefined, positiveOnly?: boolean): number | undefined;
|
|
@@ -16,7 +16,7 @@ function NumberField(props) {
|
|
|
16
16
|
// Determine default alignment based on presentation context
|
|
17
17
|
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
18
18
|
const alignment = (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.numberAlignment) === "right" ? Css_1.Css.tr.jcfe.$ : Css_1.Css.tl.jcfs.$;
|
|
19
|
-
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, sizeToContent = false, ...otherProps } = props;
|
|
19
|
+
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, sizeToContent = false, positiveOnly = false, ...otherProps } = props;
|
|
20
20
|
const isDisabled = !!disabled;
|
|
21
21
|
const isReadOnly = !!readOnly;
|
|
22
22
|
const factor = type === "percent" || type === "cents" ? 100 : type === "basisPoints" ? 10000 : 1;
|
|
@@ -56,7 +56,7 @@ function NumberField(props) {
|
|
|
56
56
|
value: valueRef.current.wip ? valueRef.current.value : value === undefined ? Number.NaN : value / factor,
|
|
57
57
|
// // This is called on blur with the final/committed value.
|
|
58
58
|
onChange: (value) => {
|
|
59
|
-
onChange(formatValue(value, factor, numFractionDigits, numIntegerDigits));
|
|
59
|
+
onChange(formatValue(value, factor, numFractionDigits, numIntegerDigits, positiveOnly));
|
|
60
60
|
},
|
|
61
61
|
onFocus: () => {
|
|
62
62
|
valueRef.current = { wip: true, value: value === undefined ? Number.NaN : value / factor };
|
|
@@ -92,11 +92,11 @@ function NumberField(props) {
|
|
|
92
92
|
// This is called on each DOM change, to push the latest value into the field
|
|
93
93
|
onChange: (rawInputValue) => {
|
|
94
94
|
const parsedValue = numberParser.parse(rawInputValue || "");
|
|
95
|
-
onChange(formatValue(parsedValue, factor, numFractionDigits, numIntegerDigits));
|
|
95
|
+
onChange(formatValue(parsedValue, factor, numFractionDigits, numIntegerDigits, positiveOnly));
|
|
96
96
|
}, inputRef: inputRef, onBlur: onBlur, onFocus: onFocus, errorMsg: errorMsg, helperText: helperText, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly), ...otherProps }));
|
|
97
97
|
}
|
|
98
98
|
exports.NumberField = NumberField;
|
|
99
|
-
function formatValue(value, factor, numFractionDigits, numIntegerDigits) {
|
|
99
|
+
function formatValue(value, factor, numFractionDigits, numIntegerDigits, positiveOnly = false) {
|
|
100
100
|
// We treat percents & cents as (mostly) integers, while useNumberField wants decimals, so
|
|
101
101
|
// undo that via `* factor` and `Math.round`, but also keep any specifically-requested `numFractionDigits`,
|
|
102
102
|
// i.e. for `type=percent value=12.34`, `value` will be `0.1234` that we want turn into `12.34`.
|
|
@@ -104,7 +104,7 @@ function formatValue(value, factor, numFractionDigits, numIntegerDigits) {
|
|
|
104
104
|
// Reverse the integer/decimal conversion
|
|
105
105
|
const decimalAdjusted = Number.isNaN(value)
|
|
106
106
|
? undefined
|
|
107
|
-
: Math.round(value * factor * maybeAdjustForDecimals) / maybeAdjustForDecimals;
|
|
107
|
+
: Math.round((positiveOnly ? Math.abs(value) : value) * factor * maybeAdjustForDecimals) / maybeAdjustForDecimals;
|
|
108
108
|
if (numIntegerDigits === undefined || decimalAdjusted === undefined) {
|
|
109
109
|
return decimalAdjusted;
|
|
110
110
|
}
|