@pdg/react-table 1.0.34 → 1.0.36
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/InfoTable/InfoTable.types.d.ts +8 -1
- package/dist/index.esm.js +17 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,9 @@ export interface InfoTableItem<T = InfoTableInfo> {
|
|
|
8
8
|
label: ReactNode;
|
|
9
9
|
name?: keyof T;
|
|
10
10
|
ellipsis?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CommonSxProps['style'];
|
|
13
|
+
sx?: BoxProps['sx'];
|
|
11
14
|
labelClassName?: string;
|
|
12
15
|
labelColor?: TypographyProps['color'];
|
|
13
16
|
labelStyle?: CommonSxProps['style'];
|
|
@@ -18,7 +21,7 @@ export interface InfoTableItem<T = InfoTableInfo> {
|
|
|
18
21
|
xs?: number;
|
|
19
22
|
onRender?(info: T): ReactNode;
|
|
20
23
|
}
|
|
21
|
-
export declare type InfoTableItems<T = InfoTableInfo> = InfoTableItem<T>[];
|
|
24
|
+
export declare type InfoTableItems<T = InfoTableInfo> = (InfoTableItem<T> | false | undefined | null)[];
|
|
22
25
|
export interface InfoTableProps<T = InfoTableInfo> {
|
|
23
26
|
cols: 1 | 2 | 3 | 4 | 6 | 12;
|
|
24
27
|
spacing?: GridProps['spacing'];
|
|
@@ -29,6 +32,10 @@ export interface InfoTableProps<T = InfoTableInfo> {
|
|
|
29
32
|
labelColor?: TypographyProps['color'];
|
|
30
33
|
labelStyle?: CommonSxProps['style'];
|
|
31
34
|
labelSx?: BoxProps['sx'];
|
|
35
|
+
valueClassName?: string;
|
|
36
|
+
valueStyle?: CommonSxProps['style'];
|
|
37
|
+
valueSx?: CommonSxProps['sx'];
|
|
38
|
+
valueUnderline?: boolean;
|
|
32
39
|
info: T;
|
|
33
40
|
items: InfoTableItems<T>;
|
|
34
41
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -9829,23 +9829,29 @@ TableButton.defaultProps = TableButtonDefaultProps;var TableMenuButtonDefaultPro
|
|
|
9829
9829
|
});
|
|
9830
9830
|
TableMenuButton.displayName = 'TableMenuButton';
|
|
9831
9831
|
TableMenuButton.defaultProps = TableMenuButtonDefaultProps;var InfoTableDefaultProps = {
|
|
9832
|
-
spacing:
|
|
9832
|
+
spacing: 2,
|
|
9833
9833
|
labelColor: 'primary',
|
|
9834
9834
|
};var Label = styled(Box)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: 12px;\n font-weight: bold;\n"], ["\n font-size: 12px;\n font-weight: bold;\n"])));
|
|
9835
|
-
var Value = styled(Box)(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])));
|
|
9835
|
+
var Value = styled(Box)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-top: 3px;\n"], ["\n margin-top: 3px;\n"])));
|
|
9836
9836
|
var ValueEllipsis = styled('div')(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"], ["\n position: relative;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
9837
9837
|
var templateObject_1, templateObject_2, templateObject_3;var InfoTable = function (_a) {
|
|
9838
|
-
var cols = _a.cols, spacing = _a.spacing, className = _a.className, style = _a.style, sx = _a.sx, labelClassName = _a.labelClassName, labelColor = _a.labelColor, labelStyle = _a.labelStyle, labelSx = _a.labelSx, info = _a.info, items = _a.items;
|
|
9838
|
+
var cols = _a.cols, spacing = _a.spacing, className = _a.className, style = _a.style, sx = _a.sx, labelClassName = _a.labelClassName, labelColor = _a.labelColor, labelStyle = _a.labelStyle, labelSx = _a.labelSx, valueClassName = _a.valueClassName, valueStyle = _a.valueStyle, valueSx = _a.valueSx, valueUnderline = _a.valueUnderline, info = _a.info, items = _a.items;
|
|
9839
9839
|
var xs = useMemo(function () { return 12 / cols; }, [cols]);
|
|
9840
9840
|
return (React__default.createElement(Grid, { container: true, spacing: spacing, className: classNames('InfoTable', className), style: style, sx: sx }, items.map(function (item, idx) {
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9841
|
+
if (item) {
|
|
9842
|
+
var finalLabelColor = typographyColorToSxColor(item.labelColor || labelColor);
|
|
9843
|
+
var finalLabelSx = combineSx(labelSx, item.labelSx, !!finalLabelColor && { color: finalLabelColor });
|
|
9844
|
+
var finalValueSx = combineSx(valueSx, item.valueSx);
|
|
9845
|
+
var valueUnderlineStyle = valueUnderline
|
|
9846
|
+
? { borderBottom: '1px solid #efefef', paddingBottom: 5 }
|
|
9847
|
+
: undefined;
|
|
9848
|
+
var data = item.name !== undefined ? info[item.name] : undefined;
|
|
9849
|
+
if (item.onRender)
|
|
9850
|
+
data = item.onRender(info);
|
|
9851
|
+
return (React__default.createElement(Grid, { key: idx, item: true, xs: item.xs || xs, className: item.className, style: item.style, sx: item.sx },
|
|
9852
|
+
React__default.createElement(Label, { className: classNames(labelClassName, item.labelClassName), style: __assign$1(__assign$1({}, item.labelStyle), labelStyle), sx: finalLabelSx }, item.label),
|
|
9853
|
+
React__default.createElement(Value, { className: classNames(valueClassName, item.valueClassName), style: __assign$1(__assign$1(__assign$1({}, valueStyle), item.valueStyle), valueUnderlineStyle), sx: finalValueSx }, item.ellipsis ? React__default.createElement(ValueEllipsis, null, data) : data)));
|
|
9854
|
+
}
|
|
9849
9855
|
})));
|
|
9850
9856
|
};
|
|
9851
9857
|
InfoTable.displayName = 'InfoTable';
|