@geotab/zenith 1.25.3 → 1.26.0-beta.1
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 +8 -2
- package/dist/absolute/absolute.d.ts +1 -0
- package/dist/absolute/absolute.js +2 -2
- package/dist/chart/barChart/getBarTooltipItems.js +2 -1
- package/dist/chart/barChart/getDefaultDatasetStyle.js +10 -3
- package/dist/chart/lineChart/getDefaultDatasetStyle.js +4 -1
- package/dist/checkbox/checkbox.d.ts +1 -0
- package/dist/checkbox/checkbox.js +10 -5
- package/dist/dataFeed/dataFeed.d.ts +13 -7
- package/dist/dataFeed/dataFeed.js +4 -7
- package/dist/dataFeed/dataFeedCell/dataFeedCell.d.ts +11 -5
- package/dist/dataFeed/dataFeedCell/dataFeedCell.js +12 -19
- package/dist/dataFeed/dataFeedColumnsItems.d.ts +11 -9
- package/dist/dataFeed/dataFeedColumnsItems.js +82 -22
- package/dist/dataFeed/dataFeedHeader/dataFeedHeader.d.ts +1 -1
- package/dist/dataFeed/feedItem/feedItem.d.ts +13 -11
- package/dist/dataFeed/feedItem/feedItem.js +17 -17
- package/dist/dataFeed/hooks/useVisibleColumns.d.ts +5 -3
- package/dist/dataGrid/cell/cell.d.ts +8 -3
- package/dist/dataGrid/cell/cell.js +22 -15
- package/dist/dataGrid/columns/actionLinkColumn/actionButtonsMobileWrapper.d.ts +2 -1
- package/dist/dataGrid/columns/actionLinkColumn/actionLinkColumn.d.ts +4 -2
- package/dist/dataGrid/columns/actionLinkColumn/actionLinkColumnWrapper.d.ts +11 -9
- package/dist/dataGrid/columns/actionsColumn/actionsColumn.d.ts +12 -11
- package/dist/dataGrid/columns/actionsColumn/actionsColumn.js +3 -3
- package/dist/dataGrid/columns/actionsColumn/actionsColumnCell.js +1 -1
- package/dist/dataGrid/columns/basicColumn.d.ts +6 -6
- package/dist/dataGrid/columns/basicColumn.js +13 -15
- package/dist/dataGrid/columns/checkboxColumn/checkboxCell.js +1 -1
- package/dist/dataGrid/columns/checkboxColumn/checkboxColumn.d.ts +7 -6
- package/dist/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.d.ts +1 -1
- package/dist/dataGrid/columns/checkboxColumn/checkboxHeaderCell.js +1 -1
- package/dist/dataGrid/columns/mainColumn/mainColumn.d.ts +9 -3
- package/dist/dataGrid/columns/mainColumn/mainColumn.js +16 -3
- package/dist/dataGrid/columns/mainColumn/mainColumnWrapper.d.ts +22 -14
- package/dist/dataGrid/columns/mainColumn/mainColumnWrapper.js +38 -23
- package/dist/dataGrid/columns/textColumn/textColumn.d.ts +3 -1
- package/dist/dataGrid/dataGrid.d.ts +8 -5
- package/dist/dataGrid/dataGrid.js +8 -6
- package/dist/dataGrid/extensions/defaultColumnComponent.d.ts +3 -2
- package/dist/dataGrid/extensions/toBasicColumn.d.ts +4 -3
- package/dist/dataGrid/getRowClassName.d.ts +1 -2
- package/dist/dataGrid/headerCell/headerCell.js +1 -1
- package/dist/dataGrid/listColumn.d.ts +28 -18
- package/dist/dataGrid/row/row.d.ts +11 -3
- package/dist/dataGrid/row/row.js +24 -13
- package/dist/dataGrid/withActions/withActions.d.ts +3 -3
- package/dist/dataGrid/withFlexibleColumns/columns/flexibleColumn.d.ts +2 -2
- package/dist/dataGrid/withFlexibleColumns/columns/flexibleColumnWrapper.d.ts +2 -1
- package/dist/dataGrid/withFlexibleColumns/components/columnSettingsList.d.ts +4 -3
- package/dist/dataGrid/withFlexibleColumns/flexibleColumnsStorage.d.ts +3 -1
- package/dist/dataGrid/withFlexibleColumns/withFlexibleColumns.d.ts +2 -2
- package/dist/dataGrid/withLoading/withLoading.d.ts +3 -3
- package/dist/dataGrid/withLoading/withLoading.js +16 -15
- package/dist/dataGrid/withSelectableRows/components/bulkActions/bulkActions.d.ts +1 -0
- package/dist/dataGrid/withSelectableRows/components/bulkActions/bulkActions.js +4 -2
- package/dist/dataGrid/withSelectableRows/withLimitedSelectableRows.d.ts +1 -1
- package/dist/dataGrid/withSelectableRows/withSelectableRows.d.ts +3 -3
- package/dist/dataGrid/withSortableColumns/columns/sortableColumn.d.ts +2 -2
- package/dist/dataGrid/withSortableColumns/columns/sortableColumnWrapper.d.ts +2 -1
- package/dist/dataGrid/withSortableColumns/withSortableColumns.d.ts +1 -1
- package/dist/index.css +449 -103
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -2
- package/dist/lineChart/utils.js +4 -1
- package/dist/nav/hooks/useExampleHook.d.ts +0 -0
- package/dist/nav/hooks/useExampleHook.js +2 -0
- package/dist/nav/nav.d.ts +6 -0
- package/dist/nav/nav.js +7 -0
- package/dist/nav/navDivider/navDivider.d.ts +4 -0
- package/dist/nav/navDivider/navDivider.js +13 -0
- package/dist/nav/navHeader/navHeader.d.ts +20 -0
- package/dist/nav/navHeader/navHeader.js +24 -0
- package/dist/nav/navItem/navItem.d.ts +23 -0
- package/dist/nav/navItem/navItem.js +56 -0
- package/dist/nav/utils/navUtils.d.ts +2 -0
- package/dist/nav/utils/navUtils.js +5 -0
- package/dist/pillExpandable/pillExpandable.js +22 -1
- package/dist/pillExpandable/pillExpandableSimple.js +2 -2
- package/dist/primaryIcon/primaryIcon.d.ts +14 -0
- package/dist/primaryIcon/primaryIcon.js +25 -0
- package/dist/primaryIcon/renderIcon.d.ts +3 -0
- package/dist/primaryIcon/renderIcon.js +12 -0
- package/dist/table/actions/actionsMenu.d.ts +5 -4
- package/dist/table/actions/actionsMenu.js +8 -8
- package/dist/table/actions/useActions.d.ts +6 -5
- package/dist/table/children/useTableChildren.d.ts +2 -1
- package/dist/table/children/useTableChildren.js +6 -3
- package/dist/table/flexible/columnsList.d.ts +4 -3
- package/dist/table/flexible/columnsPopup.d.ts +5 -4
- package/dist/table/flexible/getDefaultSettings.d.ts +2 -1
- package/dist/table/flexible/groupColumns.d.ts +2 -1
- package/dist/table/flexible/mergeColumnSettings.d.ts +3 -1
- package/dist/table/flexible/useFlexibleColumns.d.ts +4 -3
- package/dist/table/loading/useLoading.d.ts +11 -11
- package/dist/table/loading/useLoading.js +30 -14
- package/dist/table/nested/nestedData.d.ts +13 -0
- package/dist/table/nested/nestedData.js +43 -0
- package/dist/table/nested/useNestedRows.d.ts +19 -0
- package/dist/table/nested/useNestedRows.js +87 -0
- package/dist/table/selectable/calculateSelectionState.d.ts +3 -1
- package/dist/table/selectable/calculateSelectionState.js +15 -1
- package/dist/table/selectable/selectableHeader.js +1 -1
- package/dist/table/selectable/useSelectableRows.d.ts +13 -7
- package/dist/table/selectable/useSelectableRows.js +120 -40
- package/dist/table/sortable/useSortableColumns.d.ts +4 -3
- package/dist/table/table.d.ts +16 -18
- package/dist/table/table.js +8 -6
- package/dist/utils/localization/translations/cs-json.d.ts +11 -0
- package/dist/utils/localization/translations/cs-json.js +12 -1
- package/dist/utils/localization/translations/de-json.d.ts +11 -0
- package/dist/utils/localization/translations/de-json.js +12 -1
- package/dist/utils/localization/translations/en-json.d.ts +3 -0
- package/dist/utils/localization/translations/en-json.js +5 -2
- package/dist/utils/localization/translations/es-json.d.ts +11 -0
- package/dist/utils/localization/translations/es-json.js +12 -1
- package/dist/utils/localization/translations/fr-FR-json.d.ts +11 -0
- package/dist/utils/localization/translations/fr-FR-json.js +12 -1
- package/dist/utils/localization/translations/fr-json.d.ts +11 -0
- package/dist/utils/localization/translations/fr-json.js +12 -1
- package/dist/utils/localization/translations/id-json.d.ts +11 -0
- package/dist/utils/localization/translations/id-json.js +12 -1
- package/dist/utils/localization/translations/it-json.d.ts +11 -0
- package/dist/utils/localization/translations/it-json.js +12 -1
- package/dist/utils/localization/translations/ja-json.d.ts +11 -0
- package/dist/utils/localization/translations/ja-json.js +12 -1
- package/dist/utils/localization/translations/ko-KR-json.d.ts +10 -0
- package/dist/utils/localization/translations/ko-KR-json.js +11 -1
- package/dist/utils/localization/translations/ms-json.d.ts +11 -0
- package/dist/utils/localization/translations/ms-json.js +12 -1
- package/dist/utils/localization/translations/nl-json.d.ts +11 -0
- package/dist/utils/localization/translations/nl-json.js +12 -1
- package/dist/utils/localization/translations/pl-json.d.ts +11 -0
- package/dist/utils/localization/translations/pl-json.js +12 -1
- package/dist/utils/localization/translations/pt-BR-json.d.ts +11 -0
- package/dist/utils/localization/translations/pt-BR-json.js +12 -1
- package/dist/utils/localization/translations/sv-json.d.ts +11 -0
- package/dist/utils/localization/translations/sv-json.js +12 -1
- package/dist/utils/localization/translations/th-json.d.ts +11 -0
- package/dist/utils/localization/translations/th-json.js +12 -1
- package/dist/utils/localization/translations/tr-json.d.ts +11 -0
- package/dist/utils/localization/translations/tr-json.js +12 -1
- package/dist/utils/localization/translations/zh-Hans-json.d.ts +11 -0
- package/dist/utils/localization/translations/zh-Hans-json.js +12 -1
- package/dist/utils/localization/translations/zh-TW-json.d.ts +10 -0
- package/dist/utils/localization/translations/zh-TW-json.js +11 -1
- package/dist/utils/positioningUtils/calculatePosition.js +1 -4
- package/package.json +5 -4
- package/dist/table/loading/defaultColumnComponent.d.ts +0 -7
- package/dist/table/loading/defaultColumnComponent.js +0 -10
- package/dist/table/loading/getDefaultEntitiesLoadingColumn.d.ts +0 -9
- package/dist/table/loading/getDefaultEntitiesLoadingColumn.js +0 -18
package/README.md
CHANGED
|
@@ -40,9 +40,15 @@ Zenith library provides components defined in Zenith Design System. It includes
|
|
|
40
40
|
|
|
41
41
|
## Change log
|
|
42
42
|
|
|
43
|
-
### 1.
|
|
43
|
+
### 1.26.0
|
|
44
|
+
|
|
45
|
+
* Nested rows in `Table`
|
|
46
|
+
* Add translations
|
|
47
|
+
* Fix action link misalignment in `Table`
|
|
48
|
+
* Allow to define point colors in `Chart`
|
|
49
|
+
* Fix `PillExpandable` appearance in `Table`
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
### 1.25.3
|
|
46
52
|
|
|
47
53
|
* Update translations in `Chart`
|
|
48
54
|
* ColumnsSelector is right-aligned by default
|
|
@@ -17,7 +17,7 @@ const useArrowKey_1 = require("../commonHelpers/hooks/useArrowKey");
|
|
|
17
17
|
const themeContext_1 = require("../utils/theme/themeContext");
|
|
18
18
|
const useScroll_1 = require("../commonHelpers/hooks/useScroll");
|
|
19
19
|
const getScrollableParent_1 = require("../utils/getScrollableParent");
|
|
20
|
-
const Absolute = ({ isOpen, id, paddingX, paddingY, className, children, triggerRef, alignment, inline, onOpenChange, useTrapFocusWithTrigger = "off", shouldHoldScroll, stateFullChilds, role, ariaLabel, ariaLabelledby, alignmentsFn, recalculateOnScroll }) => {
|
|
20
|
+
const Absolute = ({ isOpen, id, paddingX, paddingY, className, children, triggerRef, alignment, inline, onOpenChange, useTrapFocusWithTrigger = "off", shouldHoldScroll, stateFullChilds, role, ariaLabel, ariaLabelledby, alignmentsFn, recalculateOnScroll, recalculateTrigger = true }) => {
|
|
21
21
|
const popupRef = (0, react_1.useRef)(null);
|
|
22
22
|
const prevScroll = (0, react_1.useRef)(0);
|
|
23
23
|
const { dark } = (0, react_1.useContext)(themeContext_1.themeContext);
|
|
@@ -51,7 +51,7 @@ const Absolute = ({ isOpen, id, paddingX, paddingY, className, children, trigger
|
|
|
51
51
|
const calculatePosition = (0, react_1.useCallback)(() => (0, calculatePosition_1.calculatePosition)(triggerRef, popupRef, paddingX, paddingY, inline, alignment, alignmentsFn, parent ? parent : undefined), [triggerRef, paddingX, paddingY, inline, alignment, alignmentsFn, popupRef, parent]);
|
|
52
52
|
(0, useResize_1.useResize)(calculatePosition, isOpen);
|
|
53
53
|
(0, useScroll_1.useScroll)(calculatePosition, isOpen, parent);
|
|
54
|
-
(0, react_1.useLayoutEffect)(calculatePosition, [isOpen, calculatePosition]);
|
|
54
|
+
(0, react_1.useLayoutEffect)(calculatePosition, [isOpen, children, recalculateTrigger, calculatePosition]);
|
|
55
55
|
function handleEscape() {
|
|
56
56
|
onOpenChange(false);
|
|
57
57
|
if (!triggerRef.current) {
|
|
@@ -21,7 +21,8 @@ const getBarTooltipItems = (data, datasetIndex, index, options, isHidden) => {
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
22
22
|
const value = itemValue !== undefined ? (0, formatValue_1.formatValue)(itemValue.toFixed(2), dsIndex, options === null || options === void 0 ? void 0 : options.unit) : undefined;
|
|
23
23
|
const label = dataset.label || "";
|
|
24
|
-
const color =
|
|
24
|
+
const color = Array.isArray(dataset.backgroundColor) && dataset.backgroundColor[index] ? dataset.backgroundColor[index] :
|
|
25
|
+
typeof dataset.borderColor === "string" ? dataset.borderColor : "";
|
|
25
26
|
return { label, value, color };
|
|
26
27
|
}).filter(item => item !== undefined);
|
|
27
28
|
};
|
|
@@ -10,11 +10,18 @@ const baseColors = [
|
|
|
10
10
|
"#D35D80"
|
|
11
11
|
];
|
|
12
12
|
const getDefaultDatasetStyle = (dataSet, dsIndex) => {
|
|
13
|
-
var _a;
|
|
13
|
+
var _a, _b;
|
|
14
14
|
const newDataSet = Object.assign({}, dataSet);
|
|
15
|
-
|
|
15
|
+
let baseColor;
|
|
16
|
+
if (Array.isArray(dataSet.backgroundColor) && dataSet.backgroundColor.length > 0) {
|
|
17
|
+
baseColor = (_a = dataSet.backgroundColor[0]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
18
|
+
newDataSet.backgroundColor = dataSet.backgroundColor;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
baseColor = ((_b = dataSet.backgroundColor) === null || _b === void 0 ? void 0 : _b.toString()) || baseColors[dsIndex % baseColors.length];
|
|
22
|
+
newDataSet.backgroundColor = baseColor;
|
|
23
|
+
}
|
|
16
24
|
newDataSet.borderColor = baseColor;
|
|
17
|
-
newDataSet.backgroundColor = baseColor;
|
|
18
25
|
newDataSet.barPercentage = dataSet.barPercentage !== undefined ? dataSet.barPercentage : 0.9;
|
|
19
26
|
newDataSet.categoryPercentage = dataSet.categoryPercentage !== undefined ? dataSet.categoryPercentage : 0.6;
|
|
20
27
|
return newDataSet;
|
|
@@ -23,7 +23,10 @@ const getDefaultDatasetStyle = (dataSet, dsIndex) => {
|
|
|
23
23
|
pointRs[pointRs.length - 1] = lineStyle.pointRadius;
|
|
24
24
|
newDataSet.pointRadius = pointRs;
|
|
25
25
|
newDataSet.pointHitRadius = lineStyle.pointHitRadius;
|
|
26
|
-
newDataSet.pointBackgroundColor = baseColor;
|
|
26
|
+
newDataSet.pointBackgroundColor = dataSet.pointBackgroundColor || baseColor;
|
|
27
|
+
}
|
|
28
|
+
if (dataSet.pointBackgroundColor) {
|
|
29
|
+
newDataSet.pointBorderColor = dataSet.pointBackgroundColor;
|
|
27
30
|
}
|
|
28
31
|
return newDataSet;
|
|
29
32
|
};
|
|
@@ -45,15 +45,20 @@ const useDriveClassName_1 = require("../utils/theme/useDriveClassName");
|
|
|
45
45
|
const checkboxIconCheckmark_1 = require("./checkboxIconCheckmark");
|
|
46
46
|
const checkboxIconMinus_1 = require("./checkboxIconMinus");
|
|
47
47
|
const Checkbox = (_a) => {
|
|
48
|
-
var { reverse, fullWidth, id, checked, indeterminate, title, className = "", children, disabled } = _a, rest = __rest(_a, ["reverse", "fullWidth", "id", "checked", "indeterminate", "title", "className", "children", "disabled"]);
|
|
48
|
+
var { reverse, fullWidth, id, checked, indeterminate, title, className = "", children, disabled, wrapped } = _a, rest = __rest(_a, ["reverse", "fullWidth", "id", "checked", "indeterminate", "title", "className", "children", "disabled", "wrapped"]);
|
|
49
49
|
const state = (0, checkboxUtils_1.getCheckboxState)(checked, indeterminate);
|
|
50
50
|
const generatedId = react_1.default.useId();
|
|
51
51
|
const intId = id || generatedId;
|
|
52
52
|
const driveClasses = (0, useDriveClassName_1.useDriveClassName)("zen-checkbox");
|
|
53
53
|
const checkboxIconClasses = (0, react_1.useMemo)(() => (0, classNames_1.classNames)(["zen-checkbox__icon", disabled ? "zen-checkbox__icon--disabled" : ""]), [disabled]);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const checkbox = (0, jsx_runtime_1.jsx)(triStateCheckbox_1.TriStateCheckbox, Object.assign({ className: "zen-checkbox__input", id: intId, checked: checked, indeterminate: indeterminate, disabled: disabled }, rest));
|
|
55
|
+
const iconAndLabel = (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-checkbox__box", children: state === checkboxState_1.CheckboxState.Indeterminate ? (0, jsx_runtime_1.jsx)(checkboxIconMinus_1.CheckboxIconMinus, { className: checkboxIconClasses, size: driveClasses ? "bigger" : "medium" }) :
|
|
56
|
+
state === checkboxState_1.CheckboxState.On ? (0, jsx_runtime_1.jsx)(checkboxIconCheckmark_1.CheckboxIconCheckmark, { className: checkboxIconClasses, size: driveClasses ? "bigger" : "medium" }) : null }), children
|
|
57
|
+
? (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-checkbox__label-text", fullWidth ? "zen-checkbox__label-text--full-width" : ""]), children: children })
|
|
58
|
+
: null] });
|
|
59
|
+
if (wrapped) {
|
|
60
|
+
return (0, jsx_runtime_1.jsxs)("label", { className: (0, classNames_1.classNames)(["zen-checkbox", driveClasses || "", className]), title: title, "aria-label": title, children: [checkbox, (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-checkbox__label", reverse ? "zen-checkbox__label--reverse" : ""]), children: iconAndLabel })] });
|
|
61
|
+
}
|
|
62
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-checkbox", driveClasses || "", className]), children: [checkbox, (0, jsx_runtime_1.jsx)("label", { className: (0, classNames_1.classNames)(["zen-checkbox__label", reverse ? "zen-checkbox__label--reverse" : ""]), htmlFor: intId, title: title, "aria-label": title, children: iconAndLabel })] });
|
|
58
63
|
};
|
|
59
64
|
exports.Checkbox = Checkbox;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "./dataFeed.less";
|
|
2
|
-
import {
|
|
3
|
-
import { FC, ForwardedRef, PropsWithChildren } from "react";
|
|
2
|
+
import { FC, ForwardedRef, PropsWithChildren, ReactNode } from "react";
|
|
4
3
|
import { IDataGrid } from "../dataGrid/dataGrid";
|
|
5
4
|
import { IActionWithId } from "../dataGrid/columns/actionsColumn/actionsColumn";
|
|
5
|
+
import { IRowEntity } from "../dataGrid/row/row";
|
|
6
|
+
import { IEntityWithId } from "../commonHelpers/entity";
|
|
7
|
+
export type TFeedWrapper<T, N = T> = (primaryData: ReactNode, secondaryData: ReactNode, entity: T | N, isNested: boolean) => [ReactNode, ReactNode];
|
|
6
8
|
interface IDataFeedOptions {
|
|
7
9
|
/**
|
|
8
10
|
* @deprecated - will be removed in the next major version
|
|
@@ -13,21 +15,25 @@ interface IDataFeedOptions {
|
|
|
13
15
|
scrollComponent?: HTMLElement;
|
|
14
16
|
onFeedEnd?: () => void;
|
|
15
17
|
}
|
|
16
|
-
export interface IDataFeed<T> extends IDataGrid<T> {
|
|
18
|
+
export interface IDataFeed<T, N = T> extends IDataGrid<T, N> {
|
|
19
|
+
feedWrappers?: TFeedWrapper<T, N>[];
|
|
17
20
|
expanded: boolean;
|
|
18
|
-
actions?: IActionWithId<T> | ((e: T) => JSX.Element) | undefined;
|
|
19
|
-
actionsAsync?: IActionWithId<T> | ((e: T) => PromiseLike<JSX.Element>);
|
|
21
|
+
actions?: IActionWithId<T> | ((e: T, isNested: boolean) => JSX.Element) | undefined;
|
|
22
|
+
actionsAsync?: IActionWithId<T> | ((e: T, isNested: boolean) => PromiseLike<JSX.Element>);
|
|
20
23
|
options: IDataFeedOptions;
|
|
21
24
|
itemsPerPage?: number;
|
|
25
|
+
expandedRows?: string[];
|
|
26
|
+
onExpandedChange?: (id: string, isExpanded: boolean) => void;
|
|
27
|
+
activePage?: number;
|
|
22
28
|
}
|
|
23
29
|
declare const EmptyList: FC<PropsWithChildren>;
|
|
24
30
|
declare const Footer: FC<PropsWithChildren>;
|
|
25
|
-
declare const DataFeedInner: <T extends IEntityWithId>({ entities, columns, className, expanded, options, description, children, actions, actionsAsync, itemsPerPage, rowClassName }: IDataFeed<T>, ref: ForwardedRef<HTMLElement>) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
declare const DataFeedInner: <T extends IRowEntity<N>, N extends IEntityWithId>({ entities, columns, feedWrappers, className, expanded, options, description, children, actions, actionsAsync, itemsPerPage, rowClassName, expandedRows, onExpandedChange, activePage }: IDataFeed<T, N>, ref: ForwardedRef<HTMLElement>) => import("react/jsx-runtime").JSX.Element;
|
|
26
32
|
export interface IDataFeedStaticProps {
|
|
27
33
|
EmptyList: typeof EmptyList;
|
|
28
34
|
Footer: typeof Footer;
|
|
29
35
|
}
|
|
30
|
-
declare const DataFeed: (<T>(props: IDataFeed<T> & {
|
|
36
|
+
declare const DataFeed: (<T extends IRowEntity<N>, N extends IEntityWithId = T>(props: IDataFeed<T, N> & {
|
|
31
37
|
ref?: React.ForwardedRef<HTMLElement>;
|
|
32
38
|
}) => ReturnType<typeof DataFeedInner>) & IDataFeedStaticProps;
|
|
33
39
|
export { DataFeed };
|
|
@@ -22,7 +22,7 @@ const checkCloseToTheEnd = (feedContainerElt) => {
|
|
|
22
22
|
return distanceToTheBottom < endOfFeedThreshold;
|
|
23
23
|
};
|
|
24
24
|
const FIRST_RENDERED_ROWS = 50;
|
|
25
|
-
const DataFeedInner = ({ entities, columns, className, expanded, options, description, children, actions, actionsAsync, itemsPerPage = 1000, rowClassName }, ref) => {
|
|
25
|
+
const DataFeedInner = ({ entities, columns, feedWrappers, className, expanded, options, description, children, actions, actionsAsync, itemsPerPage = 1000, rowClassName, expandedRows, onExpandedChange, activePage }, ref) => {
|
|
26
26
|
const [pages, setPages] = (0, react_1.useState)(1);
|
|
27
27
|
const data = (0, react_1.useMemo)(() => entities.slice(0, itemsPerPage * pages), [entities, itemsPerPage, pages]);
|
|
28
28
|
const initialVisibleRows = (0, react_1.useMemo)(() => data.slice(0, FIRST_RENDERED_ROWS).map(r => r.id), [data]);
|
|
@@ -35,7 +35,7 @@ const DataFeedInner = ({ entities, columns, className, expanded, options, descri
|
|
|
35
35
|
if (feedRef.current) {
|
|
36
36
|
feedRef.current.scrollTop = 0;
|
|
37
37
|
}
|
|
38
|
-
}, [
|
|
38
|
+
}, [activePage, setPages]);
|
|
39
39
|
(0, react_1.useEffect)(() => {
|
|
40
40
|
const initialRows = data.slice(0, FIRST_RENDERED_ROWS).map(r => r.id);
|
|
41
41
|
setVisibleRows(new Set(initialRows));
|
|
@@ -94,11 +94,8 @@ const DataFeedInner = ({ entities, columns, className, expanded, options, descri
|
|
|
94
94
|
}, true);
|
|
95
95
|
const feedItems = (0, react_1.useMemo)(() => data.map((entity, index) => {
|
|
96
96
|
const entityClassName = (0, getRowClassName_1.getRowClassName)(rowClassName, entity);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
return (0, jsx_runtime_1.jsx)(dataFeedColumnsItems_1.ActionFeedItem, { collapsedColumnsQty: collapsedColumnsQty, visibleColumns: visibleColumns, columnsList: columnsList, entity: entity, visibleRows: visibleRows, index: index, expanded: expanded, actions: actions, actionsAsync: actionsAsync, className: entityClassName }, entity.id);
|
|
101
|
-
}), [data, rowClassName, actions, actionsAsync, collapsedColumnsQty, visibleColumns, columnsList, visibleRows, expanded]);
|
|
97
|
+
return (0, jsx_runtime_1.jsx)(dataFeedColumnsItems_1.FeedItem, { collapsedColumnsQty: collapsedColumnsQty, columnsList: columnsList, feedWrappers: feedWrappers || [], visibleColumns: visibleColumns, entity: entity, visibleRows: visibleRows, index: index, expanded: expanded, className: entityClassName, actions: actions, actionsAsync: actionsAsync, isRowExpanded: expandedRows && expandedRows.indexOf(entity.id) > -1, onExpandedChange: (isExpanded) => onExpandedChange && onExpandedChange(entity.id, isExpanded) }, entity.id);
|
|
98
|
+
}), [data, rowClassName, collapsedColumnsQty, columnsList, feedWrappers, visibleColumns, visibleRows, expanded, actions, actionsAsync, expandedRows, onExpandedChange]);
|
|
102
99
|
return (0, jsx_runtime_1.jsx)("div", { className: "zen-data-grid-wrapper", children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)([
|
|
103
100
|
"zen-data-grid",
|
|
104
101
|
className || ""
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { IZenComponentProps } from "../../commonHelpers/zenComponent";
|
|
2
3
|
import "./dataFeedCell.less";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export interface IDataFeedCell<T extends IEntityWithId> extends IZenComponentProps {
|
|
4
|
+
import { TFeedResult } from "../../dataGrid/listColumn";
|
|
5
|
+
export interface IDataFeedCell<T extends object> extends IZenComponentProps {
|
|
6
6
|
limited?: boolean;
|
|
7
7
|
visibleOnHover?: boolean;
|
|
8
8
|
isVisible: boolean;
|
|
9
|
-
|
|
9
|
+
title: string;
|
|
10
|
+
render: (title: string, entity: T, isNested: boolean) => TFeedResult;
|
|
11
|
+
renderWrappers: (value: ReactNode | undefined, entity: T) => ReactNode;
|
|
12
|
+
renderPlaceholder: ((title: string, entity: T) => [ReactNode, ReactNode]) | undefined;
|
|
13
|
+
defaultValue: string | undefined;
|
|
10
14
|
entity: T;
|
|
15
|
+
isNested: boolean;
|
|
16
|
+
onClick?: () => void;
|
|
11
17
|
}
|
|
12
|
-
export declare const DataFeedCell: <T extends
|
|
18
|
+
export declare const DataFeedCell: <T extends object>({ limited, visibleOnHover, isVisible, title, render, renderWrappers, renderPlaceholder, defaultValue, entity, isNested }: IDataFeedCell<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,37 +5,29 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const classNames_1 = require("../../commonHelpers/classNames/classNames");
|
|
7
7
|
const basicColumn_1 = require("../../dataGrid/columns/basicColumn");
|
|
8
|
-
const
|
|
9
|
-
const FeedCell = ({ limited = false, visibleOnHover = false, isVisible, column, entity }) => {
|
|
8
|
+
const FeedCell = ({ limited = false, visibleOnHover = false, isVisible, title, render, renderWrappers, renderPlaceholder, defaultValue, entity, isNested }) => {
|
|
10
9
|
const [labelContent, setLabelContent] = (0, react_1.useState)("");
|
|
11
10
|
const [content, setContent] = (0, react_1.useState)("");
|
|
12
11
|
const placeholderRenderer = (0, react_1.useCallback)(() => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}, [column, entity]);
|
|
12
|
+
const [feedTitle, value] = renderPlaceholder ? renderPlaceholder(title, entity) : [title, "..."];
|
|
13
|
+
return [feedTitle, renderWrappers(value, entity)];
|
|
14
|
+
}, [entity, renderPlaceholder, renderWrappers, title]);
|
|
17
15
|
const renderer = (0, react_1.useCallback)(async () => {
|
|
18
16
|
let fieldValue = null;
|
|
19
|
-
const
|
|
20
|
-
? column.columnComponent.renderFeed.bind(column.columnComponent)
|
|
21
|
-
: ((title, ent) => [
|
|
22
|
-
column.columnComponent.renderHeader.call(column.columnComponent, title),
|
|
23
|
-
column.columnComponent.render.call(column.columnComponent, ent)
|
|
24
|
-
]);
|
|
25
|
-
const [label, value] = renderFeed(column.title, entity);
|
|
17
|
+
const [label, value] = render(title, entity, isNested);
|
|
26
18
|
fieldValue = value;
|
|
27
19
|
if (value === undefined || value === null) {
|
|
28
|
-
fieldValue =
|
|
20
|
+
fieldValue = defaultValue;
|
|
29
21
|
}
|
|
30
22
|
if (!(0, basicColumn_1.isPromiseLike)(fieldValue)) {
|
|
31
|
-
return [label, renderWrappers(
|
|
23
|
+
return [label, renderWrappers(fieldValue, entity)];
|
|
32
24
|
}
|
|
33
25
|
let postponedResult = await fieldValue;
|
|
34
26
|
if (postponedResult === undefined) {
|
|
35
|
-
postponedResult =
|
|
27
|
+
postponedResult = defaultValue;
|
|
36
28
|
}
|
|
37
|
-
return [label, renderWrappers(
|
|
38
|
-
}, [
|
|
29
|
+
return [label, renderWrappers(postponedResult, entity)];
|
|
30
|
+
}, [defaultValue, entity, render, renderWrappers, title, isNested]);
|
|
39
31
|
(0, react_1.useEffect)(() => {
|
|
40
32
|
if (!isVisible) {
|
|
41
33
|
setContent("");
|
|
@@ -50,7 +42,8 @@ const FeedCell = ({ limited = false, visibleOnHover = false, isVisible, column,
|
|
|
50
42
|
cancelAnimationFrame(placeholderTimeout);
|
|
51
43
|
setLabelContent(label);
|
|
52
44
|
setContent(value);
|
|
53
|
-
}).catch(() => {
|
|
45
|
+
}).catch((e) => {
|
|
46
|
+
console.error(e);
|
|
54
47
|
cancelAnimationFrame(placeholderTimeout);
|
|
55
48
|
setLabelContent("");
|
|
56
49
|
setContent("");
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IEntityWithId } from "../commonHelpers/entity";
|
|
3
2
|
import { IActionWithId } from "../dataGrid/columns/actionsColumn/actionsColumn";
|
|
4
3
|
import { IListColumnStrict } from "../dataGrid/extensions/toBasicColumn";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { IRowEntity } from "../dataGrid/row/row";
|
|
5
|
+
import { TFeedWrapper } from "./dataFeed";
|
|
6
|
+
import { IEntityWithId } from "../commonHelpers/entity";
|
|
7
|
+
interface IFeedItem<T extends IRowEntity<N>, N extends IEntityWithId> {
|
|
8
|
+
columnsList: IListColumnStrict<T, N>[];
|
|
9
|
+
feedWrappers: TFeedWrapper<T, N>[];
|
|
7
10
|
expanded: boolean;
|
|
8
11
|
/**
|
|
9
12
|
* @deprecated - will be removed in the next major version
|
|
@@ -15,11 +18,10 @@ interface IFeedItem<T extends IEntityWithId> {
|
|
|
15
18
|
entity: T;
|
|
16
19
|
index: number;
|
|
17
20
|
className?: string;
|
|
21
|
+
isRowExpanded?: boolean;
|
|
22
|
+
onExpandedChange?: (isExpanded: boolean) => void;
|
|
23
|
+
actions?: IActionWithId<T> | ((entity: T, isNested: boolean) => JSX.Element);
|
|
24
|
+
actionsAsync?: IActionWithId<T> | ((entity: T, isNested: boolean) => PromiseLike<JSX.Element>);
|
|
18
25
|
}
|
|
19
|
-
|
|
20
|
-
actions: IActionWithId<T> | ((entity: T) => JSX.Element) | undefined;
|
|
21
|
-
actionsAsync?: IActionWithId<T> | ((entity: T) => PromiseLike<JSX.Element>);
|
|
22
|
-
}
|
|
23
|
-
export declare const FeedItem: <T extends IEntityWithId>({ columnsList, expanded, collapsedColumnsQty, visibleColumns, visibleRows, entity, index, className }: IFeedItem<T>) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
-
export declare const ActionFeedItem: <T extends IEntityWithId>({ columnsList, expanded, collapsedColumnsQty, visibleColumns, visibleRows, entity, index, actions, actionsAsync, className }: IFeedActionItem<T>) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare const FeedItem: <T extends IRowEntity<N>, N extends IEntityWithId>({ columnsList, feedWrappers, expanded, collapsedColumnsQty, visibleColumns, visibleRows, entity, index, className, isRowExpanded, onExpandedChange, actions }: IFeedItem<T, N>) => import("react/jsx-runtime").JSX.Element;
|
|
25
27
|
export {};
|
|
@@ -1,37 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FeedItem = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const actionsButton_1 = require("../dataGrid/columns/actionsColumn/actionsButton");
|
|
7
7
|
const feedItem_1 = require("./feedItem/feedItem");
|
|
8
8
|
const dataFeedCell_1 = require("./dataFeedCell/dataFeedCell");
|
|
9
9
|
const actionsMenu_1 = require("../table/actions/actionsMenu");
|
|
10
|
-
const classNames_1 = require("../commonHelpers/classNames/classNames");
|
|
11
10
|
const useVisibleColumns_1 = require("./hooks/useVisibleColumns");
|
|
12
|
-
const
|
|
11
|
+
const getIconFromColumnComponent = (column, entity, isNested) => {
|
|
12
|
+
const renderIcon = ("renderIcon" in column.columnComponent) ? column.columnComponent.renderIcon.bind(column.columnComponent) : undefined;
|
|
13
|
+
if (renderIcon) {
|
|
14
|
+
return renderIcon(entity, isNested);
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
const FeedItemInner = ({ columnsList, feedWrappers, expanded, collapsedColumnsQty, visibleColumns, visibleRows, entity, index, className = "", isRowExpanded, onExpandedChange, actions }) => {
|
|
13
19
|
const { mainColumns, secondaryColumns } = (0, useVisibleColumns_1.useVisibleColumns)(columnsList, expanded, { visibleColumns, collapsedColumnsQty });
|
|
14
20
|
const mainColumnsMemoized = (0, react_1.useMemo)(() => mainColumns, [mainColumns]);
|
|
15
21
|
const secondaryColumnsMemoized = (0, react_1.useMemo)(() => secondaryColumns, [secondaryColumns]);
|
|
16
22
|
const isVisible = visibleRows.has(entity.id);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
const renderCells = (0, react_1.useCallback)((rowEntity, nested) => {
|
|
24
|
+
const getActions = () => {
|
|
25
|
+
if (!actions) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (entity.isLoading) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
if (typeof actions === "function") {
|
|
32
|
+
return (0, jsx_runtime_1.jsx)(actionsMenu_1.ActionsMenu, { entity: rowEntity, isNested: !nested, render: actions });
|
|
33
|
+
}
|
|
34
|
+
return (0, jsx_runtime_1.jsx)(actionsButton_1.ActionsButton, { action: actions, entity: rowEntity });
|
|
35
|
+
};
|
|
36
|
+
const getRenderFeed = (column) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const renderHeader = ((_a = column.columnComponent.renderHeader) === null || _a === void 0 ? void 0 : _a.bind(column.columnComponent)) || (() => column.title);
|
|
39
|
+
return (title, feedEntity, isNested) => {
|
|
40
|
+
if (column.columnComponent.renderFeed) {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
42
|
+
const result = column.columnComponent.renderFeed(title, feedEntity, isNested);
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-unnecessary-type-assertion
|
|
44
|
+
if (isNested && ("renderNested" in column.columnComponent) && column.columnComponent.renderNested) {
|
|
45
|
+
return [result[0], column.columnComponent.renderNested.call(column.columnComponent, feedEntity)];
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
50
|
+
const renderResult = column.columnComponent
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-unnecessary-type-assertion
|
|
52
|
+
? isNested && ("renderNested" in column.columnComponent) && column.columnComponent.renderNested
|
|
53
|
+
? column.columnComponent.renderNested.call(column.columnComponent, feedEntity)
|
|
54
|
+
: column.columnComponent.render.call(column.columnComponent, feedEntity, !nested)
|
|
55
|
+
: (feedEntity[column.id] || undefined);
|
|
56
|
+
return [renderHeader(title), renderResult];
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const getRenderWrappers = (column) => (value, ent) => column.wrappers.reduce((result, wrapper) => wrapper.render(result, ent, false), value);
|
|
60
|
+
const getFeedPlaceholder = (column) => {
|
|
61
|
+
if (column.meta.renderFeedPlaceholder) {
|
|
62
|
+
return column.meta.renderFeedPlaceholder;
|
|
63
|
+
}
|
|
64
|
+
return (title, ent) => [title, column.meta.renderPlaceholder ? column.meta.renderPlaceholder(ent) : "..."];
|
|
65
|
+
};
|
|
66
|
+
const getRenderFeedWrappers = (wrappers, ent, isNested) =>
|
|
67
|
+
// eslint-disable-next-line react/display-name
|
|
68
|
+
(primaryData, secondaryData) => {
|
|
69
|
+
const feedResult = wrappers.reduce((result, wrapper) => wrapper(result[0], result[1], ent, isNested), [primaryData, secondaryData]);
|
|
70
|
+
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [feedResult[0], feedResult[1]] });
|
|
71
|
+
};
|
|
72
|
+
const mainColumnsData = mainColumnsMemoized.map(column => {
|
|
73
|
+
const renderFeed = getRenderFeed(column);
|
|
74
|
+
const renderWrappers = getRenderWrappers(column);
|
|
75
|
+
const feedPlaceholder = getFeedPlaceholder(column);
|
|
76
|
+
return (0, jsx_runtime_1.jsx)(dataFeedCell_1.DataFeedCell, { limited: false, visibleOnHover: false, isVisible: isVisible, title: column.title, render: renderFeed, renderWrappers: renderWrappers, renderPlaceholder: feedPlaceholder, defaultValue: column.meta.defaultValue, entity: rowEntity, isNested: !nested }, `${entity.id}-${column.id}`);
|
|
77
|
+
});
|
|
78
|
+
const secondaryColumnsData = secondaryColumnsMemoized.map(column => {
|
|
79
|
+
const renderFeed = getRenderFeed(column);
|
|
80
|
+
const renderWrappers = getRenderWrappers(column);
|
|
81
|
+
const feedPlaceholder = getFeedPlaceholder(column);
|
|
82
|
+
return (0, jsx_runtime_1.jsx)(dataFeedCell_1.DataFeedCell, { limited: false, visibleOnHover: false, isVisible: isVisible, title: column.title, render: renderFeed, renderWrappers: renderWrappers, renderPlaceholder: feedPlaceholder, defaultValue: column.meta.defaultValue, entity: rowEntity, isNested: !nested }, `${entity.id}-${column.id}`);
|
|
83
|
+
});
|
|
84
|
+
const onItemClick = nested && onExpandedChange
|
|
85
|
+
? () => onExpandedChange(!isRowExpanded)
|
|
86
|
+
: undefined;
|
|
87
|
+
const icon = getIconFromColumnComponent(mainColumnsMemoized[0], rowEntity, !nested);
|
|
88
|
+
const actionsNode = getActions();
|
|
89
|
+
const renderFeedWrappers = getRenderFeedWrappers(feedWrappers, rowEntity, !nested);
|
|
90
|
+
const key = !nested ? `nested_${rowEntity.id}` : rowEntity.id;
|
|
91
|
+
return (0, jsx_runtime_1.jsx)(feedItem_1.DataFeedItem, { id: entity.id, index: index, onClick: onItemClick, className: className, icon: icon, identifier: mainColumnsData[0], primaryData: mainColumnsData.slice(1), secondaryData: secondaryColumnsData, actions: actionsNode, nestedData: nested && nested.length ? nested : undefined, renderFeedWrappers: renderFeedWrappers }, key);
|
|
92
|
+
}, [className, feedWrappers, index, isRowExpanded, isVisible, mainColumnsMemoized, onExpandedChange, secondaryColumnsMemoized, actions, entity]);
|
|
93
|
+
const nestedCells = (0, react_1.useMemo)(() => (entity.children && isRowExpanded ? entity.children : []).map(nestedEntity => renderCells(nestedEntity)), [entity.children, isRowExpanded, renderCells]);
|
|
94
|
+
const cells = (0, react_1.useMemo)(() => renderCells(entity, nestedCells), [entity, nestedCells, renderCells]);
|
|
95
|
+
return cells;
|
|
20
96
|
};
|
|
21
97
|
exports.FeedItem = (0, react_1.memo)(FeedItemInner);
|
|
22
|
-
const ActionFeedItemInner = ({ columnsList, expanded, collapsedColumnsQty, visibleColumns, visibleRows, entity, index, actions, actionsAsync, className }) => {
|
|
23
|
-
const actionsComp = (0, react_1.useMemo)(() => {
|
|
24
|
-
if (entity.isLoading) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
if (typeof actions === "function") {
|
|
28
|
-
return (0, jsx_runtime_1.jsx)(actionsMenu_1.ActionsMenu, { entity: entity, render: actions });
|
|
29
|
-
}
|
|
30
|
-
if (actionsAsync && typeof actionsAsync === "function") {
|
|
31
|
-
return (0, jsx_runtime_1.jsx)(actionsMenu_1.ActionsMenu, { entity: entity, renderAsync: actionsAsync });
|
|
32
|
-
}
|
|
33
|
-
return actions ? (0, jsx_runtime_1.jsx)(actionsButton_1.ActionsButton, { action: actions, entity: entity }) : null;
|
|
34
|
-
}, [actions, actionsAsync, entity]);
|
|
35
|
-
return (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-data-feed__item-container", className || ""]), children: [(0, jsx_runtime_1.jsx)(exports.FeedItem, { collapsedColumnsQty: collapsedColumnsQty, visibleColumns: visibleColumns, columnsList: columnsList, entity: entity, visibleRows: visibleRows, index: index, expanded: expanded, className: "zen-data-feed__item--no-shadow" }, entity.id), (0, jsx_runtime_1.jsx)("div", { className: "zen-data-feed__action-container", children: actionsComp })] }, entity.id);
|
|
36
|
-
};
|
|
37
|
-
exports.ActionFeedItem = (0, react_1.memo)(ActionFeedItemInner);
|
|
@@ -3,7 +3,7 @@ import { IZenComponentProps } from "./../../commonHelpers/zenComponent";
|
|
|
3
3
|
import { IEntityWithId } from "../../commonHelpers/entity";
|
|
4
4
|
import { ISortableColumn } from "../../dataGrid/withSortableColumns/columns/sortableColumn";
|
|
5
5
|
import { ISortableColumnSettings } from "../../dataGrid/withSortableColumns/sortableColumnsStorage";
|
|
6
|
-
export interface IDataFeedHeader<T> extends IZenComponentProps {
|
|
6
|
+
export interface IDataFeedHeader<T extends IEntityWithId> extends IZenComponentProps {
|
|
7
7
|
column: ISortableColumn<T>;
|
|
8
8
|
sortState?: ISortableColumnSettings;
|
|
9
9
|
onSortChange: (newSortSettings: ISortableColumnSettings) => void;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import "./feedItem.less";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export interface
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { IZenIdComponentProps } from "../../commonHelpers/zenComponent";
|
|
4
|
+
export interface IDataFeedItem extends IZenIdComponentProps {
|
|
5
5
|
index: number;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
checkbox?: ReactNode;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
identifier?: ReactNode;
|
|
9
|
+
primaryData: ReactNode;
|
|
10
|
+
secondaryData?: ReactNode;
|
|
11
|
+
actions?: ReactNode;
|
|
12
|
+
nestedData?: ReactNode;
|
|
13
|
+
renderFeedWrappers: (primaryData: ReactNode, secondaryData: ReactNode) => ReactNode;
|
|
14
|
+
onClick?: () => void;
|
|
8
15
|
}
|
|
9
|
-
export
|
|
10
|
-
Main: (props: IZenComponentProps) => ReactNode;
|
|
11
|
-
Secondary: (props: IZenComponentProps) => ReactNode;
|
|
12
|
-
}
|
|
13
|
-
declare const FeedItem: IDataFeedItem;
|
|
14
|
-
export { FeedItem as DataFeedItem };
|
|
16
|
+
export declare const DataFeedItem: ({ id, index, checkbox, icon, identifier, className, onClick, primaryData, secondaryData, actions, nestedData, renderFeedWrappers }: IDataFeedItem) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataFeedItem = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const classNames_1 = require("../../commonHelpers/classNames/classNames");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
FeedItem.Secondary = function FeedItemSection(props) {
|
|
22
|
-
return (0, jsx_runtime_1.jsx)(DataFeedSection, Object.assign({}, props));
|
|
7
|
+
const isActiveElement_1 = require("../../list/utils/isActiveElement");
|
|
8
|
+
const DataFeedItem = ({ id, index, checkbox, icon, identifier, className, onClick, primaryData, secondaryData, actions, nestedData, renderFeedWrappers }) => {
|
|
9
|
+
const onClickHandler = (0, react_1.useCallback)((e) => {
|
|
10
|
+
if ((0, isActiveElement_1.isActiveElement)(e.target)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const target = e.target;
|
|
14
|
+
if (target.className && typeof target.className === "string") {
|
|
15
|
+
if (target.className.indexOf("zen-shield") > -1) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
onClick && onClick();
|
|
20
|
+
}, [onClick]);
|
|
21
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-data-feed__item", "zen-feed-item", className || ""]), role: "article", "aria-setsize": -1, "data-row-id": id, "aria-posinset": index + 1, children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-feed-item__main-row", onClick: onClickHandler, children: renderFeedWrappers((0, jsx_runtime_1.jsxs)("div", { className: "zen-feed-item__main", children: [checkbox ? (0, jsx_runtime_1.jsx)("div", { className: "zen-feed-item__checkbox", children: checkbox }) : null, icon ? (0, jsx_runtime_1.jsx)("div", { className: "zen-feed-item__icon", children: icon }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "zen-feed-item__main-data", children: [identifier ? (0, jsx_runtime_1.jsx)("div", { className: "zen-feed-item__identifier", children: identifier }) : null, actions ? (0, jsx_runtime_1.jsx)("div", { className: "zen-feed-item__actions", children: actions }) : null] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "zen-feed-item__secondary-data", children: [icon ? (0, jsx_runtime_1.jsx)("div", { className: "zen-feed-item__icon-placeholder" }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "zen-feed-item__values", children: [primaryData, secondaryData] })] })) }), nestedData ? (0, jsx_runtime_1.jsx)("div", { className: "zen-feed-item__nested", children: nestedData }) : null] }, id);
|
|
23
22
|
};
|
|
23
|
+
exports.DataFeedItem = DataFeedItem;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { IEntityWithId } from "../../commonHelpers/entity";
|
|
1
2
|
import { IListColumnStrict } from "../../dataGrid/extensions/toBasicColumn";
|
|
3
|
+
import { IRowEntity } from "../../dataGrid/row/row";
|
|
2
4
|
interface IUseVisibleColumnsOptions {
|
|
3
5
|
visibleColumns?: number;
|
|
4
6
|
collapsedColumnsQty?: number;
|
|
5
7
|
}
|
|
6
|
-
export declare const useVisibleColumns: <T>(columnsList: IListColumnStrict<T>[], expanded: boolean, options: IUseVisibleColumnsOptions) => {
|
|
7
|
-
mainColumns: IListColumnStrict<T>[];
|
|
8
|
-
secondaryColumns: IListColumnStrict<T>[];
|
|
8
|
+
export declare const useVisibleColumns: <T extends IRowEntity<N>, N extends IEntityWithId>(columnsList: IListColumnStrict<T, N>[], expanded: boolean, options: IUseVisibleColumnsOptions) => {
|
|
9
|
+
mainColumns: IListColumnStrict<T, N>[];
|
|
10
|
+
secondaryColumns: IListColumnStrict<T, N>[];
|
|
9
11
|
};
|
|
10
12
|
export {};
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { IZenComponentProps } from "../../commonHelpers/zenComponent";
|
|
2
|
-
import { IListColumnStrict } from "../extensions/toBasicColumn";
|
|
3
3
|
import { IEntityWithId } from "../../commonHelpers/entity";
|
|
4
|
+
import { TRenderResult } from "../listColumn";
|
|
4
5
|
export interface IDataGridCell<T extends IEntityWithId> extends IZenComponentProps {
|
|
5
6
|
index: number;
|
|
6
7
|
limited: boolean;
|
|
7
8
|
visibleOnHover: boolean;
|
|
8
9
|
isVisible: boolean;
|
|
9
|
-
|
|
10
|
+
render: (entity: T) => TRenderResult;
|
|
11
|
+
renderWrappers: (value: ReactNode | undefined, entity: T) => ReactNode;
|
|
12
|
+
renderPlaceholder: ((entity: T) => ReactNode | undefined) | undefined;
|
|
13
|
+
defaultValue: string | undefined;
|
|
10
14
|
entity: T;
|
|
11
15
|
width?: number;
|
|
12
16
|
colspan?: number;
|
|
17
|
+
onClick?: () => void;
|
|
13
18
|
}
|
|
14
|
-
export declare const DataGridCell: <T extends IEntityWithId>({ index, limited, visibleOnHover, isVisible, width,
|
|
19
|
+
export declare const DataGridCell: <T extends IEntityWithId>({ index, limited, visibleOnHover, isVisible, width, render, renderWrappers, renderPlaceholder, defaultValue, entity, colspan, className, onClick }: IDataGridCell<T>) => import("react/jsx-runtime").JSX.Element;
|