@uxf/data-grid 11.74.0 → 11.74.2
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/_api/index.d.ts +8 -0
- package/_api/index.js +11 -0
- package/_components/drawer.d.ts +8 -0
- package/_components/drawer.js +19 -0
- package/_store/reducer.d.ts +8 -0
- package/_store/reducer.js +209 -0
- package/_story-utils/data.d.ts +34 -0
- package/_story-utils/data.js +229 -0
- package/_story-utils/grid-type.d.ts +32 -0
- package/_story-utils/grid-type.js +2 -0
- package/_story-utils/json-renderer.d.ts +7 -0
- package/_story-utils/json-renderer.js +12 -0
- package/_story-utils/loader.d.ts +2 -0
- package/_story-utils/loader.js +33 -0
- package/_story-utils/schema.d.ts +3 -0
- package/_story-utils/schema.js +76 -0
- package/body-cell/body-cell-boolean.d.ts +2 -0
- package/body-cell/body-cell-boolean.js +18 -0
- package/body-cell/body-cell-chip.d.ts +12 -0
- package/body-cell/body-cell-chip.js +21 -0
- package/body-cell/body-cell-date.d.ts +2 -0
- package/body-cell/body-cell-date.js +15 -0
- package/body-cell/body-cell-datetime.d.ts +2 -0
- package/body-cell/body-cell-datetime.js +15 -0
- package/body-cell/body-cell-default.d.ts +2 -0
- package/body-cell/body-cell-default.js +17 -0
- package/body-cell/body-cell-email.d.ts +2 -0
- package/body-cell/body-cell-email.js +16 -0
- package/body-cell/body-cell-money.d.ts +8 -0
- package/body-cell/body-cell-money.js +15 -0
- package/body-cell/body-cell-phone.d.ts +2 -0
- package/body-cell/body-cell-phone.js +16 -0
- package/body-cell/body-cell-to-many.d.ts +2 -0
- package/body-cell/body-cell-to-many.js +17 -0
- package/body-cell/body-cell-to-one.d.ts +2 -0
- package/body-cell/body-cell-to-one.js +14 -0
- package/body-cell/body-cell-url.d.ts +2 -0
- package/body-cell/body-cell-url.js +16 -0
- package/body-cell/index.d.ts +2 -0
- package/body-cell/index.js +33 -0
- package/components.d.ts +97 -0
- package/components.js +124 -0
- package/data-grid-custom-example.stories.d.ts +2 -0
- package/data-grid-custom-example.stories.js +58 -0
- package/data-grid-v2.d.ts +3 -0
- package/data-grid-v2.js +41 -0
- package/data-grid-v2.stories.d.ts +2 -0
- package/data-grid-v2.stories.js +99 -0
- package/data-grid.d.ts +3 -0
- package/data-grid.js +42 -0
- package/data-grid.stories.d.ts +2 -0
- package/data-grid.stories.js +106 -0
- package/export-button/export-button.d.ts +8 -0
- package/export-button/export-button.js +18 -0
- package/export-button/export-button.stories.d.ts +2 -0
- package/export-button/export-button.stories.js +17 -0
- package/export-button/index.d.ts +1 -0
- package/export-button/index.js +17 -0
- package/filter-handler/boolean-select.d.ts +4 -0
- package/filter-handler/boolean-select.js +27 -0
- package/filter-handler/checkbox.d.ts +4 -0
- package/filter-handler/checkbox.js +19 -0
- package/filter-handler/date.d.ts +7 -0
- package/filter-handler/date.js +96 -0
- package/filter-handler/datetime.d.ts +7 -0
- package/filter-handler/datetime.js +34 -0
- package/filter-handler/entity-multi-select.d.ts +5 -0
- package/filter-handler/entity-multi-select.js +27 -0
- package/filter-handler/entity-select.d.ts +5 -0
- package/filter-handler/entity-select.js +23 -0
- package/filter-handler/index.d.ts +4 -0
- package/filter-handler/index.js +41 -0
- package/filter-handler/interval.d.ts +7 -0
- package/filter-handler/interval.js +47 -0
- package/filter-handler/multi-select.d.ts +5 -0
- package/filter-handler/multi-select.js +27 -0
- package/filter-handler/select.d.ts +5 -0
- package/filter-handler/select.js +22 -0
- package/filter-handler/string.d.ts +4 -0
- package/filter-handler/string.js +26 -0
- package/filter-handler/types.d.ts +7 -0
- package/filter-handler/types.js +2 -0
- package/filter-list/filter-list.d.ts +10 -0
- package/filter-list/filter-list.js +31 -0
- package/filter-list/filter-list.stories.d.ts +2 -0
- package/filter-list/filter-list.stories.js +18 -0
- package/filter-list/index.d.ts +1 -0
- package/filter-list/index.js +17 -0
- package/filters/filters.d.ts +9 -0
- package/filters/filters.js +21 -0
- package/filters/filters.stories.d.ts +2 -0
- package/filters/filters.stories.js +18 -0
- package/filters/index.d.ts +1 -0
- package/filters/index.js +17 -0
- package/filters-button/filters-button.d.ts +10 -0
- package/filters-button/filters-button.js +47 -0
- package/filters-button/filters-button.stories.d.ts +2 -0
- package/filters-button/filters-button.stories.js +18 -0
- package/filters-button/index.d.ts +1 -0
- package/filters-button/index.js +17 -0
- package/footer/footer.d.ts +5 -0
- package/footer/footer.js +10 -0
- package/footer/index.d.ts +1 -0
- package/footer/index.js +17 -0
- package/fulltext-input/fulltext-input.d.ts +6 -0
- package/fulltext-input/fulltext-input.js +15 -0
- package/fulltext-input/fulltext-input.stories.d.ts +2 -0
- package/fulltext-input/fulltext-input.stories.js +17 -0
- package/fulltext-input/index.d.ts +1 -0
- package/fulltext-input/index.js +17 -0
- package/hidden-columns/hidden-columns.d.ts +8 -0
- package/hidden-columns/hidden-columns.js +37 -0
- package/hidden-columns/hidden-columns.stories.d.ts +2 -0
- package/hidden-columns/hidden-columns.stories.js +17 -0
- package/hidden-columns/index.d.ts +1 -0
- package/hidden-columns/index.js +17 -0
- package/hidden-columns-button/hidden-columns-button.d.ts +8 -0
- package/hidden-columns-button/hidden-columns-button.js +44 -0
- package/hidden-columns-button/hidden-columns-button.stories.d.ts +2 -0
- package/hidden-columns-button/hidden-columns-button.stories.js +17 -0
- package/hidden-columns-button/index.d.ts +1 -0
- package/hidden-columns-button/index.js +17 -0
- package/hooks/useCallbackRef.d.ts +2 -0
- package/hooks/useCallbackRef.js +6 -0
- package/index.d.ts +5 -0
- package/index.js +25 -0
- package/linear-progress/index.d.ts +1 -0
- package/linear-progress/index.js +17 -0
- package/linear-progress/linear-progress.d.ts +5 -0
- package/linear-progress/linear-progress.js +12 -0
- package/package.json +3 -3
- package/pagination/index.d.ts +1 -0
- package/pagination/index.js +17 -0
- package/pagination/pagination.d.ts +12 -0
- package/pagination/pagination.js +15 -0
- package/pagination/pagination.stories.d.ts +2 -0
- package/pagination/pagination.stories.js +17 -0
- package/root/index.d.ts +1 -0
- package/root/index.js +17 -0
- package/root/root.d.ts +6 -0
- package/root/root.js +11 -0
- package/row-counts/index.d.ts +1 -0
- package/row-counts/index.js +17 -0
- package/row-counts/row-counts.d.ts +8 -0
- package/row-counts/row-counts.js +23 -0
- package/row-counts/row-counts.stories.d.ts +2 -0
- package/row-counts/row-counts.stories.js +14 -0
- package/rows-per-page-select/index.d.ts +1 -0
- package/rows-per-page-select/index.js +17 -0
- package/rows-per-page-select/rows-per-page-select.d.ts +3 -0
- package/rows-per-page-select/rows-per-page-select.js +21 -0
- package/rows-per-page-select/rows-per-page-select.stories.d.ts +2 -0
- package/rows-per-page-select/rows-per-page-select.stories.js +17 -0
- package/selected-rows-toolbar/index.d.ts +1 -0
- package/selected-rows-toolbar/index.js +17 -0
- package/selected-rows-toolbar/selected-rows-toolbar.d.ts +11 -0
- package/selected-rows-toolbar/selected-rows-toolbar.js +33 -0
- package/selected-rows-toolbar/selected-rows-toolbar.stories.d.ts +2 -0
- package/selected-rows-toolbar/selected-rows-toolbar.stories.js +44 -0
- package/table/components/action-cell-wrapper.d.ts +6 -0
- package/table/components/action-cell-wrapper.js +57 -0
- package/table/components/action-cell.d.ts +7 -0
- package/table/components/action-cell.js +13 -0
- package/table/components/select-row-checkbox.d.ts +3 -0
- package/table/components/select-row-checkbox.js +40 -0
- package/table/hooks/use-rdg-visuals.d.ts +16 -0
- package/table/hooks/use-rdg-visuals.js +46 -0
- package/table/hooks/use-react-data-grid-columns.d.ts +4 -0
- package/table/hooks/use-react-data-grid-columns.js +86 -0
- package/table/index.d.ts +3 -0
- package/table/index.js +19 -0
- package/table/no-rows-fallback.d.ts +7 -0
- package/table/no-rows-fallback.js +16 -0
- package/table/table.d.ts +4 -0
- package/table/table.js +91 -0
- package/table/table.stories.d.ts +2 -0
- package/table/table.stories.js +20 -0
- package/table/types.d.ts +19 -0
- package/table/types.js +2 -0
- package/table-v2/components/action-cell-wrapper.d.ts +6 -0
- package/table-v2/components/action-cell-wrapper.js +10 -0
- package/table-v2/components/action-cell.d.ts +8 -0
- package/table-v2/components/action-cell.js +16 -0
- package/table-v2/components/body.d.ts +6 -0
- package/table-v2/components/body.js +10 -0
- package/table-v2/components/cell.d.ts +8 -0
- package/table-v2/components/cell.js +10 -0
- package/table-v2/components/header-action-cell.d.ts +2 -0
- package/table-v2/components/header-action-cell.js +10 -0
- package/table-v2/components/header-cell.d.ts +10 -0
- package/table-v2/components/header-cell.js +47 -0
- package/table-v2/components/header-select-all-rows-checkbox.d.ts +8 -0
- package/table-v2/components/header-select-all-rows-checkbox.js +24 -0
- package/table-v2/components/header.d.ts +6 -0
- package/table-v2/components/header.js +10 -0
- package/table-v2/components/index.d.ts +21 -0
- package/table-v2/components/index.js +26 -0
- package/table-v2/components/root.d.ts +7 -0
- package/table-v2/components/root.js +31 -0
- package/table-v2/components/row.d.ts +7 -0
- package/table-v2/components/row.js +11 -0
- package/table-v2/components/select-row-checkbox.d.ts +7 -0
- package/table-v2/components/select-row-checkbox.js +14 -0
- package/table-v2/hooks/use-resizable-columns.d.ts +9 -0
- package/table-v2/hooks/use-resizable-columns.js +69 -0
- package/table-v2/index.d.ts +1 -0
- package/table-v2/index.js +17 -0
- package/table-v2/no-rows-fallback.d.ts +7 -0
- package/table-v2/no-rows-fallback.js +16 -0
- package/table-v2/table-v2.d.ts +3 -0
- package/table-v2/table-v2.js +91 -0
- package/table-v2/table-v2.stories.d.ts +2 -0
- package/table-v2/table-v2.stories.js +23 -0
- package/table-v2/types.d.ts +23 -0
- package/table-v2/types.js +2 -0
- package/table-v2/utils/get-grid-template-columns.d.ts +9 -0
- package/table-v2/utils/get-grid-template-columns.js +23 -0
- package/table-v2/utils/get-grid-template-rows.d.ts +2 -0
- package/table-v2/utils/get-grid-template-rows.js +14 -0
- package/toolbar/index.d.ts +1 -0
- package/toolbar/index.js +17 -0
- package/toolbar/toolbar.d.ts +5 -0
- package/toolbar/toolbar.js +10 -0
- package/toolbar-control/index.d.ts +1 -0
- package/toolbar-control/index.js +17 -0
- package/toolbar-control/toolbar-control.d.ts +13 -0
- package/toolbar-control/toolbar-control.js +22 -0
- package/toolbar-control/toolbar-control.stories.d.ts +2 -0
- package/toolbar-control/toolbar-control.stories.js +19 -0
- package/toolbar-customs/index.d.ts +1 -0
- package/toolbar-customs/index.js +17 -0
- package/toolbar-customs/toolbar-customs.d.ts +13 -0
- package/toolbar-customs/toolbar-customs.js +20 -0
- package/toolbar-customs/toolbar-customs.stories.d.ts +2 -0
- package/toolbar-customs/toolbar-customs.stories.js +15 -0
- package/toolbar-tabs/index.d.ts +1 -0
- package/toolbar-tabs/index.js +17 -0
- package/toolbar-tabs/toolbar-tabs.d.ts +11 -0
- package/toolbar-tabs/toolbar-tabs.js +41 -0
- package/toolbar-tabs/toolbar-tabs.stories.d.ts +2 -0
- package/toolbar-tabs/toolbar-tabs.stories.js +17 -0
- package/translations/cs.json +47 -0
- package/translations/de.json +47 -0
- package/translations/en.json +47 -0
- package/translations/sk.json +47 -0
- package/types/api.d.ts +23 -0
- package/types/api.js +2 -0
- package/types/components.d.ts +32 -0
- package/types/components.js +2 -0
- package/types/core.d.ts +20 -0
- package/types/core.js +2 -0
- package/types/data-grid-props.d.ts +34 -0
- package/types/data-grid-props.js +2 -0
- package/types/index.d.ts +6 -0
- package/types/index.js +2 -0
- package/types/schema.d.ts +56 -0
- package/types/schema.js +2 -0
- package/types/state.d.ts +25 -0
- package/types/state.js +2 -0
- package/types/user-config-storage-adapter.d.ts +8 -0
- package/types/user-config-storage-adapter.js +2 -0
- package/use-data-grid-control/action.d.ts +47 -0
- package/use-data-grid-control/action.js +9 -0
- package/use-data-grid-control/actions-factory.d.ts +21 -0
- package/use-data-grid-control/actions-factory.js +21 -0
- package/use-data-grid-control/index.d.ts +1 -0
- package/use-data-grid-control/index.js +17 -0
- package/use-data-grid-control/use-data-grid-control.d.ts +32 -0
- package/use-data-grid-control/use-data-grid-control.js +12 -0
- package/use-data-grid-control/use-middleware-reducer.d.ts +3 -0
- package/use-data-grid-control/use-middleware-reducer.js +19 -0
- package/use-data-grid-fetching/index.d.ts +1 -0
- package/use-data-grid-fetching/index.js +17 -0
- package/use-data-grid-fetching/loader.d.ts +2 -0
- package/use-data-grid-fetching/loader.js +6 -0
- package/use-data-grid-fetching/use-data-grid-fetching.d.ts +24 -0
- package/use-data-grid-fetching/use-data-grid-fetching.js +40 -0
- package/user-config-storage-adapters/local-storage.d.ts +3 -0
- package/user-config-storage-adapters/local-storage.js +32 -0
- package/utils/create-filter-component-props.d.ts +4 -0
- package/utils/create-filter-component-props.js +15 -0
- package/utils/get-config-key.d.ts +2 -0
- package/utils/get-config-key.js +6 -0
- package/utils/merge-schema-with-config.d.ts +3 -0
- package/utils/merge-schema-with-config.js +30 -0
- package/utils/merge-schema-with-config.test.d.ts +1 -0
- package/utils/merge-schema-with-config.test.js +57 -0
- package/utils.d.ts +6 -0
- package/utils.js +37 -0
package/table/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Nullish } from "@uxf/core/types";
|
|
2
|
+
import { BodyCellComponents, DataGridActionCell, KeyExtractor, RowAccent, Schema } from "../types";
|
|
3
|
+
import { DataGridControl } from "../use-data-grid-control";
|
|
4
|
+
import { NoRowsFallbackComponent } from "./no-rows-fallback";
|
|
5
|
+
export interface DataGridTableProps<Row> extends DataGridControl {
|
|
6
|
+
schema: Schema<any>;
|
|
7
|
+
data: Row[];
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
error?: any | Nullish;
|
|
10
|
+
reload: () => Promise<any>;
|
|
11
|
+
rowHeight?: number | ((row: Row) => number);
|
|
12
|
+
headerRowHeight?: number;
|
|
13
|
+
rowClass?: (row: Row) => RowAccent;
|
|
14
|
+
keyExtractor?: KeyExtractor;
|
|
15
|
+
bodyCells?: BodyCellComponents;
|
|
16
|
+
actionCell?: DataGridActionCell<Row>;
|
|
17
|
+
NoRowsFallback?: NoRowsFallbackComponent;
|
|
18
|
+
isRowSelectable?: boolean;
|
|
19
|
+
}
|
package/table/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ActionCellWrapper = ActionCellWrapper;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function ActionCellWrapper(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__action-cell" }, props.children);
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ButtonListProps } from "@uxf/ui/button-list";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
export interface ActionCellProps {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
buttons?: ButtonListProps["buttons"];
|
|
6
|
+
visibleButtonsCount?: ButtonListProps["visibleButtonsCount"];
|
|
7
|
+
}
|
|
8
|
+
export declare function ActionCell(props: ActionCellProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ActionCell = ActionCell;
|
|
7
|
+
const is_not_empty_1 = require("@uxf/core/utils/is-not-empty");
|
|
8
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
9
|
+
const button_list_1 = require("@uxf/ui/button-list");
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
11
|
+
function ActionCell(props) {
|
|
12
|
+
var _a;
|
|
13
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
14
|
+
(0, is_not_nil_1.isNotNil)(props.buttons) && (0, is_not_empty_1.isNotEmpty)(props.buttons) && (react_1.default.createElement(button_list_1.ButtonList, { buttons: props.buttons, size: "sm", variant: "secondary", visibleButtonsCount: (_a = props.visibleButtonsCount) !== null && _a !== void 0 ? _a : 0 })),
|
|
15
|
+
props.children));
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Body = Body;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Body(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__body" }, props.children);
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Cell = Cell;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Cell(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: `uxf-dg-table__cell uxf-dg-table__cell--type-${props.column.type}` }, props.children);
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HeaderActionCell = HeaderActionCell;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function HeaderActionCell() {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__action-cell uxf-dg-table__action-cell--header" });
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Nullish } from "@uxf/core/types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Column, DataGridSort } from "../../types";
|
|
4
|
+
export interface HeaderCellProps {
|
|
5
|
+
column: Column<any, any>;
|
|
6
|
+
onResizeStart: () => void;
|
|
7
|
+
sort: DataGridSort | Nullish;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const HeaderCell: React.ForwardRefExoticComponent<HeaderCellProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.HeaderCell = void 0;
|
|
27
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
28
|
+
const icon_1 = require("@uxf/ui/icon");
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
function HeaderCellComponent(props, ref) {
|
|
31
|
+
var _a, _b, _c, _d;
|
|
32
|
+
const iconName = !props.column.sort
|
|
33
|
+
? null
|
|
34
|
+
: ((_a = props.sort) === null || _a === void 0 ? void 0 : _a.dir) === "asc"
|
|
35
|
+
? "sort-up"
|
|
36
|
+
: ((_b = props.sort) === null || _b === void 0 ? void 0 : _b.dir) === "desc"
|
|
37
|
+
? "sort-down"
|
|
38
|
+
: "sort";
|
|
39
|
+
return (
|
|
40
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
41
|
+
react_1.default.createElement("div", { className: (0, cx_1.cx)(`uxf-dg-table__cell uxf-dg-table__cell--header uxf-dg-table__cell--type-${props.column.type}`, props.column.sort && "is-sortable", ((_c = props.sort) === null || _c === void 0 ? void 0 : _c.dir) === "asc" && "is-sorted-asc", ((_d = props.sort) === null || _d === void 0 ? void 0 : _d.dir) === "desc" && "is-sorted-desc"), onClick: props.onClick, ref: ref },
|
|
42
|
+
props.column.label,
|
|
43
|
+
iconName && react_1.default.createElement(icon_1.Icon, { className: "ml-auto", name: iconName }),
|
|
44
|
+
react_1.default.createElement("button", { className: "uxf-dg-table__column-resize-handle", onClick: (event) => event.stopPropagation(), onMouseDown: props.onResizeStart })));
|
|
45
|
+
}
|
|
46
|
+
exports.HeaderCell = (0, react_1.forwardRef)(HeaderCellComponent);
|
|
47
|
+
exports.HeaderCell.displayName = "HeaderCell";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { KeyExtractor } from "../../types";
|
|
3
|
+
import { DataGridTableProps } from "../types";
|
|
4
|
+
interface SelectRowCheckboxProps extends Pick<DataGridTableProps<any>, "state" | "data" | "actions"> {
|
|
5
|
+
keyExtractor: KeyExtractor;
|
|
6
|
+
}
|
|
7
|
+
export declare function HeaderSelectAllRowsCheckbox(props: SelectRowCheckboxProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HeaderSelectAllRowsCheckbox = HeaderSelectAllRowsCheckbox;
|
|
7
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
8
|
+
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
9
|
+
const is_not_empty_1 = require("@uxf/core/utils/is-not-empty");
|
|
10
|
+
const checkbox_input_1 = require("@uxf/ui/checkbox-input");
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
function HeaderSelectAllRowsCheckbox(props) {
|
|
13
|
+
var _a;
|
|
14
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
15
|
+
const selectedRows = (_a = props.state.selectedRows) !== null && _a !== void 0 ? _a : empty_array_1.EMPTY_ARRAY;
|
|
16
|
+
const isAllRowsSelected = (0, is_not_empty_1.isNotEmpty)(props.data) &&
|
|
17
|
+
props.data.every((row) => selectedRows.find((selectedRow) => props.keyExtractor(row) === props.keyExtractor(selectedRow)));
|
|
18
|
+
const isIndeterminate = !isAllRowsSelected && (0, is_not_empty_1.isNotEmpty)(selectedRows);
|
|
19
|
+
const selectAllRowsHandler = () => {
|
|
20
|
+
props.actions.setSelectedRows(isAllRowsSelected ? [] : props.data);
|
|
21
|
+
};
|
|
22
|
+
return (react_1.default.createElement("div", { className: "uxf-dg-table__cell uxf-dg-table__cell--header uxf-dg-table__select-all-rows-cell" },
|
|
23
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { hiddenLabel: true, indeterminate: isIndeterminate, label: t("uxf-data-grid-checkboxes:select-all"), name: "select-all-rows", onChange: selectAllRowsHandler, value: isAllRowsSelected })));
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Header = Header;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Header(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__header" }, props.children);
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ActionCell } from "./action-cell";
|
|
2
|
+
import { ActionCellWrapper } from "./action-cell-wrapper";
|
|
3
|
+
import { Body } from "./body";
|
|
4
|
+
import { Cell } from "./cell";
|
|
5
|
+
import { Header } from "./header";
|
|
6
|
+
import { HeaderActionCell } from "./header-action-cell";
|
|
7
|
+
import { HeaderSelectAllRowsCheckbox } from "./header-select-all-rows-checkbox";
|
|
8
|
+
import { Row } from "./row";
|
|
9
|
+
import { SelectRowCheckbox } from "./select-row-checkbox";
|
|
10
|
+
export declare const Table: import("react").ForwardRefExoticComponent<import("./root").RootProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
11
|
+
Body: typeof Body;
|
|
12
|
+
Row: typeof Row;
|
|
13
|
+
HeaderCell: import("react").ForwardRefExoticComponent<import("./header-cell").HeaderCellProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
Cell: typeof Cell;
|
|
15
|
+
ActionCell: typeof ActionCell;
|
|
16
|
+
ActionCellWrapper: typeof ActionCellWrapper;
|
|
17
|
+
HeaderActionCell: typeof HeaderActionCell;
|
|
18
|
+
Header: typeof Header;
|
|
19
|
+
SelectRowCheckbox: typeof SelectRowCheckbox;
|
|
20
|
+
HeaderSelectAllRowsCheckbox: typeof HeaderSelectAllRowsCheckbox;
|
|
21
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Table = void 0;
|
|
4
|
+
const action_cell_1 = require("./action-cell");
|
|
5
|
+
const action_cell_wrapper_1 = require("./action-cell-wrapper");
|
|
6
|
+
const body_1 = require("./body");
|
|
7
|
+
const cell_1 = require("./cell");
|
|
8
|
+
const header_1 = require("./header");
|
|
9
|
+
const header_action_cell_1 = require("./header-action-cell");
|
|
10
|
+
const header_cell_1 = require("./header-cell");
|
|
11
|
+
const header_select_all_rows_checkbox_1 = require("./header-select-all-rows-checkbox");
|
|
12
|
+
const root_1 = require("./root");
|
|
13
|
+
const row_1 = require("./row");
|
|
14
|
+
const select_row_checkbox_1 = require("./select-row-checkbox");
|
|
15
|
+
exports.Table = Object.assign(root_1.Root, {
|
|
16
|
+
Body: body_1.Body,
|
|
17
|
+
Row: row_1.Row,
|
|
18
|
+
HeaderCell: header_cell_1.HeaderCell,
|
|
19
|
+
Cell: cell_1.Cell,
|
|
20
|
+
ActionCell: action_cell_1.ActionCell,
|
|
21
|
+
ActionCellWrapper: action_cell_wrapper_1.ActionCellWrapper,
|
|
22
|
+
HeaderActionCell: header_action_cell_1.HeaderActionCell,
|
|
23
|
+
Header: header_1.Header,
|
|
24
|
+
SelectRowCheckbox: select_row_checkbox_1.SelectRowCheckbox,
|
|
25
|
+
HeaderSelectAllRowsCheckbox: header_select_all_rows_checkbox_1.HeaderSelectAllRowsCheckbox,
|
|
26
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export interface RootProps {
|
|
3
|
+
gridTemplateColumns: string;
|
|
4
|
+
gridTemplateRows?: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Root = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
function RootComponent(props, ref) {
|
|
29
|
+
return (react_1.default.createElement("div", { className: "uxf-dg-table", ref: ref, style: { gridTemplateColumns: props.gridTemplateColumns, gridTemplateRows: props.gridTemplateRows } }, props.children));
|
|
30
|
+
}
|
|
31
|
+
exports.Root = (0, react_1.forwardRef)(RootComponent);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Row = Row;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Row(props) {
|
|
9
|
+
var _a;
|
|
10
|
+
return react_1.default.createElement("div", { className: `uxf-dg-table__row ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` }, props.children);
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SelectRowCheckbox = SelectRowCheckbox;
|
|
7
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
8
|
+
const checkbox_input_1 = require("@uxf/ui/checkbox-input");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
function SelectRowCheckbox(props) {
|
|
11
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
12
|
+
return (react_1.default.createElement("div", { className: "uxf-dg-table__cell uxf-dg-table__select-row-cell" },
|
|
13
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: "*:mt-0", hiddenLabel: true, label: t("uxf-data-grid-checkboxes:select"), name: "select-row", onChange: props.onSelectRowChange, value: props.isRowSelected })));
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Nullish } from "@uxf/core/types";
|
|
2
|
+
import { Column } from "../../types";
|
|
3
|
+
import { DataGridControl } from "../../use-data-grid-control";
|
|
4
|
+
import { DataGridTableProps } from "../types";
|
|
5
|
+
export declare function useResizableColumns(columns: Column<any, any>[], actionCell: DataGridTableProps<any>["actionCell"], actions: DataGridControl["actions"], selectRowsCellWidth: number | Nullish): {
|
|
6
|
+
tableRef: import("react").RefObject<HTMLDivElement>;
|
|
7
|
+
columnRefs: import("react").MutableRefObject<(HTMLDivElement | null)[]>;
|
|
8
|
+
onResizeStart(index: number): void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useResizableColumns = useResizableColumns;
|
|
4
|
+
const is_empty_1 = require("@uxf/core/utils/is-empty");
|
|
5
|
+
const rem_1 = require("@uxf/styles/units/rem");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const get_grid_template_columns_1 = require("../utils/get-grid-template-columns");
|
|
8
|
+
const COLUMN_ABSOLUTE_MIN_WIDTH = 50;
|
|
9
|
+
function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth) {
|
|
10
|
+
const [activeIndex, setActiveIndex] = (0, react_1.useState)(null);
|
|
11
|
+
const tableRef = (0, react_1.useRef)(null);
|
|
12
|
+
const columnRefs = (0, react_1.useRef)([]);
|
|
13
|
+
const actionCellWidth = actionCell === null || actionCell === void 0 ? void 0 : actionCell.width;
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
let tempColumnSizes = [];
|
|
16
|
+
const onMouseMove = (e) => {
|
|
17
|
+
const gridColumns = columns.map((column, i) => {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
|
+
const columnRef = columnRefs.current[i];
|
|
20
|
+
const columnMinWidth = (_b = (_a = column.config) === null || _a === void 0 ? void 0 : _a.minWidth) !== null && _b !== void 0 ? _b : COLUMN_ABSOLUTE_MIN_WIDTH;
|
|
21
|
+
if (i === activeIndex) {
|
|
22
|
+
const tableScrollLeft = (_d = (_c = tableRef.current) === null || _c === void 0 ? void 0 : _c.scrollLeft) !== null && _d !== void 0 ? _d : 0;
|
|
23
|
+
const columnOffsetLeft = (_e = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetLeft) !== null && _e !== void 0 ? _e : 0;
|
|
24
|
+
const clickPositionX = e.clientX + tableScrollLeft;
|
|
25
|
+
const width = clickPositionX - columnOffsetLeft;
|
|
26
|
+
return width >= columnMinWidth ? width : columnMinWidth;
|
|
27
|
+
}
|
|
28
|
+
return (_f = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetWidth) !== null && _f !== void 0 ? _f : columnMinWidth;
|
|
29
|
+
});
|
|
30
|
+
// TODO @vejvis - jak tohle udělat lépe??
|
|
31
|
+
tempColumnSizes = gridColumns;
|
|
32
|
+
if (tableRef.current) {
|
|
33
|
+
tableRef.current.style.gridTemplateColumns = (0, get_grid_template_columns_1.getGridTemplateColumns)({
|
|
34
|
+
actionColumnWidth: actionCellWidth,
|
|
35
|
+
columns: gridColumns.map((size) => ({
|
|
36
|
+
width: (0, rem_1.rem)(size),
|
|
37
|
+
minWidth: null,
|
|
38
|
+
})),
|
|
39
|
+
selectRowColumnWidth: selectRowsCellWidth,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const onMouseUp = () => {
|
|
44
|
+
setActiveIndex(null);
|
|
45
|
+
if (!(0, is_empty_1.isEmpty)(tempColumnSizes)) {
|
|
46
|
+
const userConfigColumns = {};
|
|
47
|
+
columns.forEach((column, index) => {
|
|
48
|
+
userConfigColumns[column.name] = { width: tempColumnSizes[index] };
|
|
49
|
+
});
|
|
50
|
+
actions.updateUserConfig({ columns: userConfigColumns });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
if (activeIndex !== null) {
|
|
54
|
+
window.addEventListener("mousemove", onMouseMove);
|
|
55
|
+
window.addEventListener("mouseup", onMouseUp);
|
|
56
|
+
}
|
|
57
|
+
return () => {
|
|
58
|
+
window.removeEventListener("mousemove", onMouseMove);
|
|
59
|
+
window.removeEventListener("mouseup", onMouseUp);
|
|
60
|
+
};
|
|
61
|
+
}, [columns, actions, actionCellWidth, activeIndex, selectRowsCellWidth]);
|
|
62
|
+
return {
|
|
63
|
+
tableRef,
|
|
64
|
+
columnRefs,
|
|
65
|
+
onResizeStart(index) {
|
|
66
|
+
setActiveIndex(index);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./table-v2";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./table-v2"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
export interface NoRowsFallbackProps {
|
|
3
|
+
error?: any;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type NoRowsFallbackComponent = FunctionComponent<NoRowsFallbackProps>;
|
|
7
|
+
export declare function NoRowsFallback(props: NoRowsFallbackProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NoRowsFallback = NoRowsFallback;
|
|
7
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
8
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
9
|
+
const icon_1 = require("@uxf/ui/icon");
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
11
|
+
function NoRowsFallback(props) {
|
|
12
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
13
|
+
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-dg-table__no-rows-fallback", props.isLoading && "is-loading", props.error && "is-error") }, props.isLoading ? (react_1.default.createElement(react_1.default.Fragment, null, t("uxf-data-grid-no-rows-fallback:loading"))) : props.error ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
14
|
+
react_1.default.createElement(icon_1.Icon, { name: "warning", size: 24 }),
|
|
15
|
+
react_1.default.createElement("p", null, t("uxf-data-grid-no-rows-fallback:error")))) : (react_1.default.createElement(react_1.default.Fragment, null, t("uxf-data-grid-no-rows-fallback:no-records")))));
|
|
16
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DataGridTableV2 = DataGridTableV2;
|
|
7
|
+
const show_1 = require("@uxf/core-react/components/show");
|
|
8
|
+
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
9
|
+
const is_empty_1 = require("@uxf/core/utils/is-empty");
|
|
10
|
+
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
11
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
12
|
+
const format_css_value_1 = require("@uxf/styles/units/format-css-value");
|
|
13
|
+
const rem_1 = require("@uxf/styles/units/rem");
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const components_1 = require("./components");
|
|
16
|
+
const header_select_all_rows_checkbox_1 = require("./components/header-select-all-rows-checkbox");
|
|
17
|
+
const select_row_checkbox_1 = require("./components/select-row-checkbox");
|
|
18
|
+
const use_resizable_columns_1 = require("./hooks/use-resizable-columns");
|
|
19
|
+
const no_rows_fallback_1 = require("./no-rows-fallback");
|
|
20
|
+
const get_grid_template_columns_1 = require("./utils/get-grid-template-columns");
|
|
21
|
+
const get_grid_template_rows_1 = require("./utils/get-grid-template-rows");
|
|
22
|
+
const SELECT_ROWS_CELL_WIDTH = 32;
|
|
23
|
+
const defaultKeyExtractor = (r) => r.id;
|
|
24
|
+
const DefaultBodyCell = () => "Unknown body cell.";
|
|
25
|
+
function DataGridTableV2(props) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
|
+
const keyExtractor = (_a = props.keyExtractor) !== null && _a !== void 0 ? _a : defaultKeyExtractor;
|
|
28
|
+
const visibleColumns = props.schema.columns
|
|
29
|
+
.filter((column) => !column.hidden)
|
|
30
|
+
.filter((column) => { var _a, _b, _c, _d; return !((_c = (_b = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b.isHidden) !== null && _c !== void 0 ? _c : (_d = column.config) === null || _d === void 0 ? void 0 : _d.isHidden); });
|
|
31
|
+
const selectedRowColumnWidth = props.isRowSelectable ? SELECT_ROWS_CELL_WIDTH : null;
|
|
32
|
+
const { tableRef, columnRefs, onResizeStart } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions, selectedRowColumnWidth);
|
|
33
|
+
const gridTemplateRows = (0, get_grid_template_rows_1.getGridTemplateRows)(props.data, (_b = props.headerRowHeight) !== null && _b !== void 0 ? _b : 36, (_c = props.rowHeight) !== null && _c !== void 0 ? _c : 44);
|
|
34
|
+
const gridTemplateBasicColumns = visibleColumns
|
|
35
|
+
.map((column) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const userColumnConfig = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name];
|
|
38
|
+
const hasUserConfigWidthOrMinWidth = (userColumnConfig === null || userColumnConfig === void 0 ? void 0 : userColumnConfig.width) || (userColumnConfig === null || userColumnConfig === void 0 ? void 0 : userColumnConfig.minWidth);
|
|
39
|
+
return hasUserConfigWidthOrMinWidth ? userColumnConfig : column.config;
|
|
40
|
+
})
|
|
41
|
+
.map((columnConfig) => {
|
|
42
|
+
var _a;
|
|
43
|
+
return ({
|
|
44
|
+
width: (0, is_nil_1.isNil)(columnConfig === null || columnConfig === void 0 ? void 0 : columnConfig.width) ? "1fr" : ((_a = (0, format_css_value_1.formatCssValue)(columnConfig.width)) !== null && _a !== void 0 ? _a : ""),
|
|
45
|
+
minWidth: (0, is_nil_1.isNil)(columnConfig === null || columnConfig === void 0 ? void 0 : columnConfig.minWidth) ? null : (0, rem_1.rem)(columnConfig.minWidth),
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
const gridTemplateColumns = (0, get_grid_template_columns_1.getGridTemplateColumns)({
|
|
49
|
+
columns: gridTemplateBasicColumns,
|
|
50
|
+
selectRowColumnWidth: selectedRowColumnWidth,
|
|
51
|
+
actionColumnWidth: (_d = props.actionCell) === null || _d === void 0 ? void 0 : _d.width,
|
|
52
|
+
});
|
|
53
|
+
const selectedRows = (_e = props.state.selectedRows) !== null && _e !== void 0 ? _e : empty_array_1.EMPTY_ARRAY;
|
|
54
|
+
const selectRowHandler = (rowId) => () => {
|
|
55
|
+
const isRowSelected = selectedRows.find((r) => keyExtractor(r) === rowId);
|
|
56
|
+
const newSelectedRows = isRowSelected
|
|
57
|
+
? selectedRows.filter((row) => keyExtractor(row) !== rowId)
|
|
58
|
+
: [...selectedRows, props.data.find((row) => keyExtractor(row) === rowId)];
|
|
59
|
+
props.actions.setSelectedRows(newSelectedRows);
|
|
60
|
+
};
|
|
61
|
+
const NoRowsFallback = (_f = props.NoRowsFallback) !== null && _f !== void 0 ? _f : no_rows_fallback_1.NoRowsFallback;
|
|
62
|
+
return (react_1.default.createElement(components_1.Table, { gridTemplateColumns: gridTemplateColumns, gridTemplateRows: gridTemplateRows, ref: tableRef },
|
|
63
|
+
react_1.default.createElement(components_1.Table.Header, null,
|
|
64
|
+
react_1.default.createElement(components_1.Table.Row, null,
|
|
65
|
+
react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowSelectable) },
|
|
66
|
+
react_1.default.createElement(header_select_all_rows_checkbox_1.HeaderSelectAllRowsCheckbox, { actions: props.actions, data: props.data, keyExtractor: keyExtractor, state: props.state })),
|
|
67
|
+
visibleColumns.map((column, index) => {
|
|
68
|
+
var _a;
|
|
69
|
+
return (react_1.default.createElement(components_1.Table.HeaderCell, { column: column, key: column.name, onClick: column.sort ? () => props.actions.sort(column.name) : undefined, onResizeStart: () => onResizeStart(index), ref: (el) => {
|
|
70
|
+
columnRefs.current[index] = el;
|
|
71
|
+
}, sort: ((_a = props.state.request.s) === null || _a === void 0 ? void 0 : _a.name) === column.name ? props.state.request.s : null }));
|
|
72
|
+
}),
|
|
73
|
+
react_1.default.createElement(show_1.Show, { when: (0, is_not_nil_1.isNotNil)(props.actionCell) },
|
|
74
|
+
react_1.default.createElement(components_1.Table.HeaderActionCell, null)))),
|
|
75
|
+
react_1.default.createElement(components_1.Table.Body, null, (0, is_empty_1.isEmpty)(props.data) ? (react_1.default.createElement(NoRowsFallback, { error: props.error, isLoading: Boolean(props.isLoading) })) : (props.data.map((row) => {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
return (react_1.default.createElement(components_1.Table.Row, { className: `${(0, is_not_nil_1.isNotNil)(props.rowAccent) ? "uxf-dg-table__row--" + props.rowAccent(row) : ""} ${(_b = (_a = props.rowClassName) === null || _a === void 0 ? void 0 : _a.call(props, row)) !== null && _b !== void 0 ? _b : ""}`, key: keyExtractor(row) },
|
|
78
|
+
react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowSelectable) },
|
|
79
|
+
react_1.default.createElement(select_row_checkbox_1.SelectRowCheckbox, { isRowSelected: selectedRows.find((r) => keyExtractor(r) === keyExtractor(row)), onSelectRowChange: selectRowHandler(keyExtractor(row)) })),
|
|
80
|
+
visibleColumns.map((column) => {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
82
|
+
const BodyCell =
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
84
|
+
(_d = (_b = (_a = props.bodyCells) === null || _a === void 0 ? void 0 : _a[column.type]) !== null && _b !== void 0 ? _b : (_c = props.bodyCells) === null || _c === void 0 ? void 0 : _c.default) !== null && _d !== void 0 ? _d : DefaultBodyCell;
|
|
85
|
+
return (react_1.default.createElement(components_1.Table.Cell, { column: column, key: column.name },
|
|
86
|
+
react_1.default.createElement(BodyCell, { column: column, reload: props.reload, row: row, value: row[column.name] })));
|
|
87
|
+
}),
|
|
88
|
+
(0, is_not_nil_1.isNotNil)(props.actionCell) && (react_1.default.createElement(components_1.Table.ActionCellWrapper, null,
|
|
89
|
+
react_1.default.createElement(props.actionCell.Component, { reload: props.reload, row: row })))));
|
|
90
|
+
})))));
|
|
91
|
+
}
|