@pdg/react-table 1.0.36 → 1.0.38
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 +14 -1
- package/dist/index.esm.js +35 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,11 +19,23 @@ export interface InfoTableItem<T = InfoTableInfo> {
|
|
|
19
19
|
valueStyle?: CommonSxProps['style'];
|
|
20
20
|
valueSx?: CommonSxProps['sx'];
|
|
21
21
|
xs?: number;
|
|
22
|
+
sm?: number;
|
|
23
|
+
md?: number;
|
|
24
|
+
lg?: number;
|
|
25
|
+
xl?: number;
|
|
22
26
|
onRender?(info: T): ReactNode;
|
|
27
|
+
onRenderEmpty?(info: T): ReactNode;
|
|
23
28
|
}
|
|
24
29
|
export declare type InfoTableItems<T = InfoTableInfo> = (InfoTableItem<T> | false | undefined | null)[];
|
|
30
|
+
export declare type InfoTableCols = 1 | 2 | 3 | 4 | 6 | 12;
|
|
25
31
|
export interface InfoTableProps<T = InfoTableInfo> {
|
|
26
|
-
cols:
|
|
32
|
+
cols: InfoTableCols | {
|
|
33
|
+
xs?: InfoTableCols;
|
|
34
|
+
sm?: InfoTableCols;
|
|
35
|
+
md?: InfoTableCols;
|
|
36
|
+
lg?: InfoTableCols;
|
|
37
|
+
xl?: InfoTableCols;
|
|
38
|
+
};
|
|
27
39
|
spacing?: GridProps['spacing'];
|
|
28
40
|
className?: string;
|
|
29
41
|
style?: CommonSxProps['style'];
|
|
@@ -35,6 +47,7 @@ export interface InfoTableProps<T = InfoTableInfo> {
|
|
|
35
47
|
valueClassName?: string;
|
|
36
48
|
valueStyle?: CommonSxProps['style'];
|
|
37
49
|
valueSx?: CommonSxProps['sx'];
|
|
50
|
+
ellipsis?: boolean;
|
|
38
51
|
valueUnderline?: boolean;
|
|
39
52
|
info: T;
|
|
40
53
|
items: InfoTableItems<T>;
|
package/dist/index.esm.js
CHANGED
|
@@ -9835,8 +9835,26 @@ TableMenuButton.defaultProps = TableMenuButtonDefaultProps;var InfoTableDefaultP
|
|
|
9835
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, valueClassName = _a.valueClassName, valueStyle = _a.valueStyle, valueSx = _a.valueSx, valueUnderline = _a.valueUnderline, info = _a.info, items = _a.items;
|
|
9839
|
-
var
|
|
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, ellipsis = _a.ellipsis, valueUnderline = _a.valueUnderline, info = _a.info, items = _a.items;
|
|
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
9859
|
if (item) {
|
|
9842
9860
|
var finalLabelColor = typographyColorToSxColor(item.labelColor || labelColor);
|
|
@@ -9845,12 +9863,25 @@ var templateObject_1, templateObject_2, templateObject_3;var InfoTable = functio
|
|
|
9845
9863
|
var valueUnderlineStyle = valueUnderline
|
|
9846
9864
|
? { borderBottom: '1px solid #efefef', paddingBottom: 5 }
|
|
9847
9865
|
: undefined;
|
|
9866
|
+
var finalSizeProps = __assign$1({}, sizeProps);
|
|
9867
|
+
if (item.xs)
|
|
9868
|
+
finalSizeProps.xs = item.xs;
|
|
9869
|
+
if (item.sm)
|
|
9870
|
+
finalSizeProps.sm = item.sm;
|
|
9871
|
+
if (item.md)
|
|
9872
|
+
finalSizeProps.md = item.md;
|
|
9873
|
+
if (item.lg)
|
|
9874
|
+
finalSizeProps.lg = item.lg;
|
|
9875
|
+
if (item.xl)
|
|
9876
|
+
finalSizeProps.xl = item.xl;
|
|
9848
9877
|
var data = item.name !== undefined ? info[item.name] : undefined;
|
|
9849
9878
|
if (item.onRender)
|
|
9850
9879
|
data = item.onRender(info);
|
|
9851
|
-
|
|
9880
|
+
if (empty(data))
|
|
9881
|
+
data = item.onRenderEmpty ? item.onRenderEmpty(info) : React__default.createElement(React__default.Fragment, null, "\u00A0");
|
|
9882
|
+
return (React__default.createElement(Grid, __assign$1({ key: idx, item: true }, finalSizeProps, { className: item.className, style: item.style, sx: item.sx }),
|
|
9852
9883
|
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)));
|
|
9884
|
+
React__default.createElement(Value, { className: classNames(valueClassName, item.valueClassName), style: __assign$1(__assign$1(__assign$1({}, valueStyle), item.valueStyle), valueUnderlineStyle), sx: finalValueSx }, item.ellipsis || ellipsis ? React__default.createElement(ValueEllipsis, null, data) : data)));
|
|
9854
9885
|
}
|
|
9855
9886
|
})));
|
|
9856
9887
|
};
|