@pdg/react-table 1.0.35 → 1.0.37
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 +9 -2
- package/dist/index.esm.js +33 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +33 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -21,9 +21,16 @@ export interface InfoTableItem<T = InfoTableInfo> {
|
|
|
21
21
|
xs?: number;
|
|
22
22
|
onRender?(info: T): ReactNode;
|
|
23
23
|
}
|
|
24
|
-
export declare type InfoTableItems<T = InfoTableInfo> = InfoTableItem<T>[];
|
|
24
|
+
export declare type InfoTableItems<T = InfoTableInfo> = (InfoTableItem<T> | false | undefined | null)[];
|
|
25
|
+
export declare type InfoTableCols = 1 | 2 | 3 | 4 | 6 | 12;
|
|
25
26
|
export interface InfoTableProps<T = InfoTableInfo> {
|
|
26
|
-
cols:
|
|
27
|
+
cols: InfoTableCols | {
|
|
28
|
+
xs?: InfoTableCols;
|
|
29
|
+
sm?: InfoTableCols;
|
|
30
|
+
md?: InfoTableCols;
|
|
31
|
+
lg?: InfoTableCols;
|
|
32
|
+
xl?: InfoTableCols;
|
|
33
|
+
};
|
|
27
34
|
spacing?: GridProps['spacing'];
|
|
28
35
|
className?: string;
|
|
29
36
|
style?: CommonSxProps['style'];
|
package/dist/index.esm.js
CHANGED
|
@@ -9836,20 +9836,40 @@ var Value = styled(Box)(templateObject_2 || (templateObject_2 = __makeTemplateOb
|
|
|
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
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
|
-
var
|
|
9839
|
+
var sizeProps = useMemo(function () {
|
|
9840
|
+
var value = {};
|
|
9841
|
+
if (typeof cols === 'number') {
|
|
9842
|
+
value.xs = 12 / cols;
|
|
9843
|
+
}
|
|
9844
|
+
else {
|
|
9845
|
+
if (cols.xs)
|
|
9846
|
+
value.xs = 12 / cols.xs;
|
|
9847
|
+
if (cols.sm)
|
|
9848
|
+
value.sm = 12 / cols.sm;
|
|
9849
|
+
if (cols.md)
|
|
9850
|
+
value.md = 12 / cols.md;
|
|
9851
|
+
if (cols.lg)
|
|
9852
|
+
value.lg = 12 / cols.lg;
|
|
9853
|
+
if (cols.xl)
|
|
9854
|
+
value.xl = 12 / cols.xl;
|
|
9855
|
+
}
|
|
9856
|
+
return value;
|
|
9857
|
+
}, [cols]);
|
|
9840
9858
|
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
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
React__default.createElement(
|
|
9852
|
-
|
|
9859
|
+
if (item) {
|
|
9860
|
+
var finalLabelColor = typographyColorToSxColor(item.labelColor || labelColor);
|
|
9861
|
+
var finalLabelSx = combineSx(labelSx, item.labelSx, !!finalLabelColor && { color: finalLabelColor });
|
|
9862
|
+
var finalValueSx = combineSx(valueSx, item.valueSx);
|
|
9863
|
+
var valueUnderlineStyle = valueUnderline
|
|
9864
|
+
? { borderBottom: '1px solid #efefef', paddingBottom: 5 }
|
|
9865
|
+
: undefined;
|
|
9866
|
+
var data = item.name !== undefined ? info[item.name] : undefined;
|
|
9867
|
+
if (item.onRender)
|
|
9868
|
+
data = item.onRender(info);
|
|
9869
|
+
return (React__default.createElement(Grid, __assign$1({ key: idx, item: true }, sizeProps, { className: item.className, style: item.style, sx: item.sx }),
|
|
9870
|
+
React__default.createElement(Label, { className: classNames(labelClassName, item.labelClassName), style: __assign$1(__assign$1({}, item.labelStyle), labelStyle), sx: finalLabelSx }, item.label),
|
|
9871
|
+
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)));
|
|
9872
|
+
}
|
|
9853
9873
|
})));
|
|
9854
9874
|
};
|
|
9855
9875
|
InfoTable.displayName = 'InfoTable';
|