@true-engineering/true-react-common-ui-kit 3.50.1 → 3.51.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.
- package/README.md +6 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +2 -3
- package/dist/true-react-common-ui-kit.js +23 -22
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +23 -22
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/FlexibleTable/FlexibleTable.tsx +12 -12
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +3 -5
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ import { ICommonProps } from '../../types';
|
|
|
3
3
|
import { IFlexibleTableRowProps } from './components';
|
|
4
4
|
import { ITableRow, IFlexibleTableConfigType, IInfinityScrollConfig, IFlexibleTableRenderMode, IHeaderContent } from './types';
|
|
5
5
|
import { IFlexibleTableStyles } from './FlexibleTable.styles';
|
|
6
|
-
export interface IFlexibleTableProps<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row> extends ICommonProps<IFlexibleTableStyles>, Pick<IFlexibleTableRowProps<Row, HeaderContent, UniqueField>, 'uniqueField' | 'rowAttributes' | 'isFirstColumnSticky' | '
|
|
6
|
+
export interface IFlexibleTableProps<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row> extends ICommonProps<IFlexibleTableStyles>, Pick<IFlexibleTableRowProps<Row, HeaderContent, UniqueField>, 'uniqueField' | 'rowAttributes' | 'isFirstColumnSticky' | 'expandableRowComponent' | 'onRowClick' | 'onRowHover' | 'rowRef'> {
|
|
7
7
|
content: Row[];
|
|
8
8
|
/** @default 'table' */
|
|
9
9
|
renderMode?: IFlexibleTableRenderMode;
|
|
@@ -27,5 +27,7 @@ export interface IFlexibleTableProps<Row extends ITableRow, HeaderContent extend
|
|
|
27
27
|
nothingFoundContent?: ReactNode;
|
|
28
28
|
/** @default true */
|
|
29
29
|
shouldRenderHeader?: boolean;
|
|
30
|
+
/** @default false */
|
|
31
|
+
isExpandableRowComponentInitiallyOpen?: boolean | ((row: Row, index: number) => boolean);
|
|
30
32
|
}
|
|
31
|
-
export declare function FlexibleTable<Row extends ITableRow, HeaderContent extends IHeaderContent<Row> = IHeaderContent<Row>, UniqueField extends keyof Row = keyof Row>({ content, headerContent, config, enabledColumns, activeRows, uniqueField, isLoading, isFirstColumnSticky, isHorizontallyScrollable, isRowFocusable, infinityScrollConfig, renderMode, refForScroll, nothingFoundContent, data, testId, tweakStyles, shouldRenderHeader, onHeadClick, ...restProps }: IFlexibleTableProps<Row, HeaderContent, UniqueField>): JSX.Element;
|
|
33
|
+
export declare function FlexibleTable<Row extends ITableRow, HeaderContent extends IHeaderContent<Row> = IHeaderContent<Row>, UniqueField extends keyof Row = keyof Row>({ content, headerContent, config, enabledColumns, activeRows, uniqueField, isLoading, isFirstColumnSticky, isHorizontallyScrollable, isRowFocusable, infinityScrollConfig, renderMode, refForScroll, nothingFoundContent, data, testId, tweakStyles, shouldRenderHeader, onHeadClick, isExpandableRowComponentInitiallyOpen: isRowInitiallyOpen, ...restProps }: IFlexibleTableProps<Row, HeaderContent, UniqueField>): JSX.Element;
|
|
@@ -4,7 +4,6 @@ import { ITableRow, IFlexibleTableConfigType, IFlexibleTableRenderMode, IHeaderC
|
|
|
4
4
|
import { IFlexibleTableRowStyles } from './FlexibleTableRow.styles';
|
|
5
5
|
export interface IFlexibleTableRowProps<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row> extends ITweakStylesProps<IFlexibleTableRowStyles> {
|
|
6
6
|
item: Row;
|
|
7
|
-
index: number;
|
|
8
7
|
uniqueField?: UniqueField;
|
|
9
8
|
renderMode: IFlexibleTableRenderMode;
|
|
10
9
|
/** @default false */
|
|
@@ -20,13 +19,13 @@ export interface IFlexibleTableRowProps<Row extends ITableRow, HeaderContent ext
|
|
|
20
19
|
columns: Array<keyof Row & string>;
|
|
21
20
|
rowAttributes?: Array<keyof Row>;
|
|
22
21
|
/** @default false */
|
|
23
|
-
isExpandableRowComponentInitiallyOpen?: boolean
|
|
22
|
+
isExpandableRowComponentInitiallyOpen?: boolean;
|
|
24
23
|
rowRef?: RefCallback<HTMLTableRowElement>;
|
|
25
24
|
/** Возвращает React-элемент, который отрисуется под строкой при нажатии на неё */
|
|
26
25
|
expandableRowComponent?: (item: Row, isOpen: boolean, close: () => void) => ReactNode;
|
|
27
26
|
onRowHover?: (id?: Row[UniqueField]) => void;
|
|
28
27
|
onRowClick?: (id: Row[UniqueField]) => void;
|
|
29
28
|
}
|
|
30
|
-
declare function FlexibleTableRowInner<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row>({ item,
|
|
29
|
+
declare function FlexibleTableRowInner<Row extends ITableRow, HeaderContent extends IHeaderContent<Row>, UniqueField extends keyof Row>({ item, config, columns, uniqueField, renderMode, isActive, isFocusable, isFirstColumnSticky, isLoading, rowAttributes, isExpandableRowComponentInitiallyOpen, rowRef, tweakStyles, expandableRowComponent, onRowHover, onRowClick, }: IFlexibleTableRowProps<Row, HeaderContent, UniqueField>): JSX.Element;
|
|
31
30
|
export declare const FlexibleTableRow: typeof FlexibleTableRowInner;
|
|
32
31
|
export {};
|
|
@@ -26347,7 +26347,7 @@ function _unsupported_iterable_to_array$7(o, minLen) {
|
|
|
26347
26347
|
return _array_like_to_array$7(o, minLen);
|
|
26348
26348
|
}
|
|
26349
26349
|
function FlexibleTableRowInner(param) {
|
|
26350
|
-
var item = param.item,
|
|
26350
|
+
var item = param.item, config = param.config, columns = param.columns, uniqueField = param.uniqueField, renderMode = param.renderMode, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isFocusable = param.isFocusable, isFocusable = _param_isFocusable === void 0 ? false : _param_isFocusable, _param_isFirstColumnSticky = param.isFirstColumnSticky, isFirstColumnSticky = _param_isFirstColumnSticky === void 0 ? false : _param_isFirstColumnSticky, _param_isLoading = param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, rowAttributes = param.rowAttributes, _param_isExpandableRowComponentInitiallyOpen = param.isExpandableRowComponentInitiallyOpen, isExpandableRowComponentInitiallyOpen = _param_isExpandableRowComponentInitiallyOpen === void 0 ? false : _param_isExpandableRowComponentInitiallyOpen, rowRef = param.rowRef, tweakStyles = param.tweakStyles, expandableRowComponent = param.expandableRowComponent, onRowHover = param.onRowHover, onRowClick = param.onRowClick;
|
|
26351
26351
|
var classes = useStyles$h({
|
|
26352
26352
|
theme: tweakStyles
|
|
26353
26353
|
});
|
|
@@ -26359,7 +26359,7 @@ function FlexibleTableRowInner(param) {
|
|
|
26359
26359
|
var _useState = _sliced_to_array$7(useState(false), 2), isFocused = _useState[0], setFocused = _useState[1];
|
|
26360
26360
|
var _useState1 = _sliced_to_array$7(useState(function() {
|
|
26361
26361
|
return {
|
|
26362
|
-
isOpen:
|
|
26362
|
+
isOpen: isExpandableRowComponentInitiallyOpen
|
|
26363
26363
|
};
|
|
26364
26364
|
}), 2), nestedComponent = _useState1[0], setNestedComponent = _useState1[1];
|
|
26365
26365
|
var isEditable = !isLoading && (isNotEmpty(onRowClick) || isNotEmpty(onRowHover));
|
|
@@ -26552,7 +26552,7 @@ function _object_without_properties_loose$7(source, excluded) {
|
|
|
26552
26552
|
return target;
|
|
26553
26553
|
}
|
|
26554
26554
|
function FlexibleTable(_param) {
|
|
26555
|
-
var content = _param.content, headerContent = _param.headerContent, config = _param.config, enabledColumns = _param.enabledColumns, activeRows = _param.activeRows, uniqueField = _param.uniqueField, _param_isLoading = _param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, _param_isFirstColumnSticky = _param.isFirstColumnSticky, isFirstColumnSticky = _param_isFirstColumnSticky === void 0 ? false : _param_isFirstColumnSticky, _param_isHorizontallyScrollable = _param.isHorizontallyScrollable, isHorizontallyScrollable = _param_isHorizontallyScrollable === void 0 ? false : _param_isHorizontallyScrollable, _param_isRowFocusable = _param.isRowFocusable, isRowFocusable = _param_isRowFocusable === void 0 ? false : _param_isRowFocusable, infinityScrollConfig = _param.infinityScrollConfig, _param_renderMode = _param.renderMode, renderMode = _param_renderMode === void 0 ? "table" : _param_renderMode, refForScroll = _param.refForScroll, nothingFoundContent = _param.nothingFoundContent, data = _param.data, testId = _param.testId, tweakStyles = _param.tweakStyles, _param_shouldRenderHeader = _param.shouldRenderHeader, shouldRenderHeader = _param_shouldRenderHeader === void 0 ? true : _param_shouldRenderHeader, onHeadClick = _param.onHeadClick, restProps = _object_without_properties$7(_param, [
|
|
26555
|
+
var content = _param.content, headerContent = _param.headerContent, config = _param.config, enabledColumns = _param.enabledColumns, activeRows = _param.activeRows, uniqueField = _param.uniqueField, _param_isLoading = _param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, _param_isFirstColumnSticky = _param.isFirstColumnSticky, isFirstColumnSticky = _param_isFirstColumnSticky === void 0 ? false : _param_isFirstColumnSticky, _param_isHorizontallyScrollable = _param.isHorizontallyScrollable, isHorizontallyScrollable = _param_isHorizontallyScrollable === void 0 ? false : _param_isHorizontallyScrollable, _param_isRowFocusable = _param.isRowFocusable, isRowFocusable = _param_isRowFocusable === void 0 ? false : _param_isRowFocusable, infinityScrollConfig = _param.infinityScrollConfig, _param_renderMode = _param.renderMode, renderMode = _param_renderMode === void 0 ? "table" : _param_renderMode, refForScroll = _param.refForScroll, nothingFoundContent = _param.nothingFoundContent, data = _param.data, testId = _param.testId, tweakStyles = _param.tweakStyles, _param_shouldRenderHeader = _param.shouldRenderHeader, shouldRenderHeader = _param_shouldRenderHeader === void 0 ? true : _param_shouldRenderHeader, onHeadClick = _param.onHeadClick, isRowInitiallyOpen = _param.isExpandableRowComponentInitiallyOpen, restProps = _object_without_properties$7(_param, [
|
|
26556
26556
|
"content",
|
|
26557
26557
|
"headerContent",
|
|
26558
26558
|
"config",
|
|
@@ -26571,7 +26571,8 @@ function FlexibleTable(_param) {
|
|
|
26571
26571
|
"testId",
|
|
26572
26572
|
"tweakStyles",
|
|
26573
26573
|
"shouldRenderHeader",
|
|
26574
|
-
"onHeadClick"
|
|
26574
|
+
"onHeadClick",
|
|
26575
|
+
"isExpandableRowComponentInitiallyOpen"
|
|
26575
26576
|
]);
|
|
26576
26577
|
var classes = useStyles$j({
|
|
26577
26578
|
theme: tweakStyles
|
|
@@ -26590,16 +26591,20 @@ function FlexibleTable(_param) {
|
|
|
26590
26591
|
config
|
|
26591
26592
|
]);
|
|
26592
26593
|
var hasInfiniteScroll = isNotEmpty(infinityScrollConfig);
|
|
26593
|
-
var
|
|
26594
|
-
|
|
26595
|
-
|
|
26596
|
-
|
|
26597
|
-
|
|
26598
|
-
|
|
26599
|
-
|
|
26600
|
-
|
|
26601
|
-
|
|
26602
|
-
|
|
26594
|
+
var getTableRowProps = function(item, index) {
|
|
26595
|
+
return _object_spread_props$j(_object_spread$k({}, restProps), {
|
|
26596
|
+
item,
|
|
26597
|
+
renderMode,
|
|
26598
|
+
config,
|
|
26599
|
+
columns,
|
|
26600
|
+
uniqueField,
|
|
26601
|
+
isLoading,
|
|
26602
|
+
isFirstColumnSticky,
|
|
26603
|
+
isFocusable: isRowFocusable,
|
|
26604
|
+
tweakStyles: tweakTableRowStyles,
|
|
26605
|
+
isExpandableRowComponentInitiallyOpen: applyAction(isRowInitiallyOpen, item, index)
|
|
26606
|
+
});
|
|
26607
|
+
};
|
|
26603
26608
|
var getDataScrollAttributeSetter = useCallback(function(key, setter) {
|
|
26604
26609
|
return function(el) {
|
|
26605
26610
|
if (isHorizontallyScrollable && isNotEmpty(el) && setter(el)) {
|
|
@@ -26725,10 +26730,8 @@ function FlexibleTable(_param) {
|
|
|
26725
26730
|
/* @__PURE__ */ jsx(Table.Body, {
|
|
26726
26731
|
className: classes.body,
|
|
26727
26732
|
children: isLoading ? indexMap(6, function(i) {
|
|
26728
|
-
return /* @__PURE__ */ createElement(FlexibleTableRow, _object_spread_props$j(_object_spread$k({},
|
|
26729
|
-
key: i
|
|
26730
|
-
item: {},
|
|
26731
|
-
index: i
|
|
26733
|
+
return /* @__PURE__ */ createElement(FlexibleTableRow, _object_spread_props$j(_object_spread$k({}, getTableRowProps({}, i)), {
|
|
26734
|
+
key: i
|
|
26732
26735
|
}));
|
|
26733
26736
|
}) : /* @__PURE__ */ jsxs(Fragment, {
|
|
26734
26737
|
children: [
|
|
@@ -26741,11 +26744,9 @@ function FlexibleTable(_param) {
|
|
|
26741
26744
|
})
|
|
26742
26745
|
}),
|
|
26743
26746
|
content.map(function(item, i) {
|
|
26744
|
-
return /* @__PURE__ */ createElement(FlexibleTableRow, _object_spread_props$j(_object_spread$k({},
|
|
26747
|
+
return /* @__PURE__ */ createElement(FlexibleTableRow, _object_spread_props$j(_object_spread$k({}, getTableRowProps(item, i)), {
|
|
26745
26748
|
isActive: activeRowsSet.has(i),
|
|
26746
|
-
key: isNotEmpty(uniqueField) ? item[uniqueField] : i
|
|
26747
|
-
item,
|
|
26748
|
-
index: i
|
|
26749
|
+
key: isNotEmpty(uniqueField) ? item[uniqueField] : i
|
|
26749
26750
|
}));
|
|
26750
26751
|
}),
|
|
26751
26752
|
hasInfiniteScroll && !infinityScrollConfig.isLastPage && /* @__PURE__ */ jsx(Table.Row, {
|