@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
|
@@ -0,0 +1,21 @@
|
|
|
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.DataGridRowsPerPageSelect = DataGridRowsPerPageSelect;
|
|
7
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
8
|
+
const select_1 = require("@uxf/ui/select");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const PER_PAGE_OPTIONS = [
|
|
11
|
+
{ id: 10, label: "10" },
|
|
12
|
+
{ id: 25, label: "25" },
|
|
13
|
+
{ id: 50, label: "50" },
|
|
14
|
+
{ id: 100, label: "100" },
|
|
15
|
+
];
|
|
16
|
+
function DataGridRowsPerPageSelect(props) {
|
|
17
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
18
|
+
return (react_1.default.createElement("div", { className: "uxf-data-grid__rows-per-page" },
|
|
19
|
+
react_1.default.createElement("label", { htmlFor: "uxf-data-grid--select-per-page" }, t("uxf-data-grid-rows-per-page-select:rows-count-label")),
|
|
20
|
+
react_1.default.createElement(select_1.Select, { hiddenLabel: true, id: "uxf-data-grid--select-per-page", label: t("uxf-data-grid-rows-per-page-select:rows-count-label"), name: "rows-per-page", onChange: (value) => props.actions.changePerPage(value !== null && value !== void 0 ? value : 10), options: PER_PAGE_OPTIONS, size: "small", value: props.state.request.perPage })));
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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.Default = Default;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const json_renderer_1 = require("../_story-utils/json-renderer");
|
|
9
|
+
const schema_1 = require("../_story-utils/schema");
|
|
10
|
+
const use_data_grid_control_1 = require("../use-data-grid-control");
|
|
11
|
+
const rows_per_page_select_1 = require("./rows-per-page-select");
|
|
12
|
+
function Default() {
|
|
13
|
+
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
|
|
14
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
15
|
+
react_1.default.createElement(rows_per_page_select_1.DataGridRowsPerPageSelect, { actions: actions, state: state }),
|
|
16
|
+
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./selected-rows-toolbar";
|
|
@@ -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("./selected-rows-toolbar"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
import { DataGridControl } from "../use-data-grid-control";
|
|
3
|
+
export interface SelectedRowsToolbarActionsProps extends DataGridControl {
|
|
4
|
+
reload: () => Promise<any>;
|
|
5
|
+
}
|
|
6
|
+
export type SelectedRowsToolbarActionsComponent = FunctionComponent<SelectedRowsToolbarActionsProps>;
|
|
7
|
+
export interface DataGridSelectedRowsToolbarProps extends DataGridControl {
|
|
8
|
+
Actions?: SelectedRowsToolbarActionsComponent;
|
|
9
|
+
reload: () => Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
export declare function DataGridSelectedRowsToolbar(props: DataGridSelectedRowsToolbarProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
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.DataGridSelectedRowsToolbar = DataGridSelectedRowsToolbar;
|
|
7
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
8
|
+
const button_1 = require("@uxf/ui/button");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const getText = (count, t) => {
|
|
11
|
+
if (count === 1) {
|
|
12
|
+
return t("uxf-data-grid-selected-rows-toolbar:selected-one");
|
|
13
|
+
}
|
|
14
|
+
if (count < 5) {
|
|
15
|
+
return t("uxf-data-grid-selected-rows-toolbar:selected-few", { count });
|
|
16
|
+
}
|
|
17
|
+
return t("uxf-data-grid-selected-rows-toolbar:selected-many", { count });
|
|
18
|
+
};
|
|
19
|
+
function DataGridSelectedRowsToolbar(props) {
|
|
20
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
21
|
+
if (!props.state.selectedRows) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (props.state.selectedRows.length === 0) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return (react_1.default.createElement("div", { className: "uxf-data-grid__selected-rows-toolbar-wrapper", style: { paddingLeft: 240 } },
|
|
28
|
+
react_1.default.createElement("div", { className: "uxf-data-grid__selected-rows-toolbar" },
|
|
29
|
+
react_1.default.createElement("p", null, getText(props.state.selectedRows.length, t)),
|
|
30
|
+
react_1.default.createElement("div", { className: "uxf-data-grid__selected-rows-toolbar-actions" },
|
|
31
|
+
props.Actions && (react_1.default.createElement(props.Actions, { actions: props.actions, reload: props.reload, state: props.state })),
|
|
32
|
+
react_1.default.createElement(button_1.Button, { onClick: () => props.actions.setSelectedRows([]) }, t("uxf-data-grid-selected-rows-toolbar:cancel-selection"))))));
|
|
33
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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.Default = Default;
|
|
27
|
+
const button_1 = require("@uxf/ui/button");
|
|
28
|
+
const icon_1 = require("@uxf/ui/icon");
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const json_renderer_1 = require("../_story-utils/json-renderer");
|
|
31
|
+
const schema_1 = require("../_story-utils/schema");
|
|
32
|
+
const use_data_grid_control_1 = require("../use-data-grid-control");
|
|
33
|
+
const selected_rows_toolbar_1 = require("./selected-rows-toolbar");
|
|
34
|
+
function Default() {
|
|
35
|
+
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
|
|
36
|
+
const reload = () => new Promise(() => null);
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
actions.setSelectedRows([{ id: 1 }, { id: 2 }]);
|
|
39
|
+
}, [actions]);
|
|
40
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
41
|
+
react_1.default.createElement(selected_rows_toolbar_1.DataGridSelectedRowsToolbar, { Actions: () => (react_1.default.createElement(button_1.Button, { isIconButton: true },
|
|
42
|
+
react_1.default.createElement(icon_1.Icon, { name: "camera" }))), actions: actions, reload: reload, state: state }),
|
|
43
|
+
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
44
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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.ActionCellWrapper = ActionCellWrapper;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
function ActionCellWrapper(props) {
|
|
29
|
+
const innerRef = (0, react_1.useRef)(null);
|
|
30
|
+
(0, react_1.useEffect)(() => {
|
|
31
|
+
var _a;
|
|
32
|
+
let scrollLeft = 0;
|
|
33
|
+
let grid = null;
|
|
34
|
+
const node = innerRef.current;
|
|
35
|
+
if (!node) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const scrollHandler = () => {
|
|
39
|
+
grid === null || grid === void 0 ? void 0 : grid.scrollTo({ left: scrollLeft });
|
|
40
|
+
grid === null || grid === void 0 ? void 0 : grid.removeEventListener("scroll", scrollHandler);
|
|
41
|
+
};
|
|
42
|
+
const focusHandler = () => {
|
|
43
|
+
grid = node.closest(".rdg");
|
|
44
|
+
if (grid) {
|
|
45
|
+
scrollLeft = grid.scrollLeft;
|
|
46
|
+
grid.addEventListener("scroll", scrollHandler);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
(_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.addEventListener("focus", focusHandler, { capture: true });
|
|
50
|
+
return () => {
|
|
51
|
+
var _a;
|
|
52
|
+
grid === null || grid === void 0 ? void 0 : grid.removeEventListener("scroll", scrollHandler);
|
|
53
|
+
(_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.removeEventListener("focus", focusHandler);
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
return (react_1.default.createElement("div", { className: "uxf-data-grid__action-cell-wrapper", ref: innerRef }, props.children));
|
|
57
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ButtonListProps } from "@uxf/ui/button-list";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export interface ActionCellProps {
|
|
4
|
+
buttons: ButtonListProps["buttons"];
|
|
5
|
+
visibleButtonsCount: ButtonListProps["visibleButtonsCount"];
|
|
6
|
+
}
|
|
7
|
+
export declare function ActionCell(props: ActionCellProps): React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 button_list_1 = require("@uxf/ui/button-list");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const action_cell_wrapper_1 = require("./action-cell-wrapper");
|
|
10
|
+
function ActionCell(props) {
|
|
11
|
+
return (react_1.default.createElement(action_cell_wrapper_1.ActionCellWrapper, null,
|
|
12
|
+
react_1.default.createElement(button_list_1.ButtonList, { buttons: props.buttons, size: "sm", variant: "secondary", visibleButtonsCount: props.visibleButtonsCount })));
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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.SelectRowCheckbox = SelectRowCheckbox;
|
|
27
|
+
const checkbox_1 = require("@uxf/ui/checkbox");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
function SelectRowCheckbox(props) {
|
|
30
|
+
var _a;
|
|
31
|
+
const handleChange = (value, e) => {
|
|
32
|
+
if (typeof value !== "undefined") {
|
|
33
|
+
const shiftKey = (e === null || e === void 0 ? void 0 : e.nativeEvent) && e.nativeEvent instanceof MouseEvent ? e.nativeEvent.shiftKey : false;
|
|
34
|
+
props.onChange(value, shiftKey);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const id = (0, react_1.useId)();
|
|
38
|
+
return (react_1.default.createElement("div", { className: "uxf-data-grid__select-row-checkbox-wrapper" },
|
|
39
|
+
react_1.default.createElement(checkbox_1.Checkbox, { ...props, name: id, onChange: handleChange, value: (_a = props.checked) !== null && _a !== void 0 ? _a : false })));
|
|
40
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataGridHandle } from "react-data-grid";
|
|
2
|
+
import { BaseGridType, DataGridBaseProps } from "../../types";
|
|
3
|
+
export declare function useRdgVisuals(props: {
|
|
4
|
+
headerRowHeight?: DataGridBaseProps<BaseGridType, any>["headerRowHeight"];
|
|
5
|
+
rowHeight?: Exclude<DataGridBaseProps<BaseGridType, any>["rowHeight"], "auto">;
|
|
6
|
+
rows: any[];
|
|
7
|
+
}): {
|
|
8
|
+
className: string;
|
|
9
|
+
headerRowHeight: number;
|
|
10
|
+
ready: boolean;
|
|
11
|
+
ref: import("react").RefObject<DataGridHandle>;
|
|
12
|
+
rowHeight: number | ((row: any) => number);
|
|
13
|
+
style: {
|
|
14
|
+
height: number | undefined;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRdgVisuals = useRdgVisuals;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useRdgVisuals(props) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const [mounted, setMounted] = (0, react_1.useState)(false);
|
|
8
|
+
(0, react_1.useEffect)(() => setMounted(true), []);
|
|
9
|
+
const rowHeight = (_a = props.rowHeight) !== null && _a !== void 0 ? _a : 44;
|
|
10
|
+
const headerRowHeight = (_b = props.headerRowHeight) !== null && _b !== void 0 ? _b : 36;
|
|
11
|
+
const contentHeight = typeof rowHeight === "function"
|
|
12
|
+
? props.rows.reduce((prev, curr) => prev + rowHeight(curr))
|
|
13
|
+
: rowHeight * props.rows.length;
|
|
14
|
+
const ref = (0, react_1.useRef)(null);
|
|
15
|
+
const size = {
|
|
16
|
+
contentHeight,
|
|
17
|
+
headerRowHeight,
|
|
18
|
+
rowsCount: props.rows.length,
|
|
19
|
+
};
|
|
20
|
+
const storedSize = (0, react_1.useRef)(size);
|
|
21
|
+
storedSize.current = size;
|
|
22
|
+
const [height, setHeight] = (0, react_1.useState)();
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
var _a;
|
|
25
|
+
const node = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.element;
|
|
26
|
+
if (!(mounted && node)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const observer = new MutationObserver((mutations) => mutations.forEach(() => {
|
|
30
|
+
const currentSize = storedSize.current;
|
|
31
|
+
const scrollbarHeight = node.scrollWidth > node.clientWidth ? 8 : 0;
|
|
32
|
+
const emptyRowHeight = currentSize.rowsCount === 0 ? 44 : 0;
|
|
33
|
+
setHeight(currentSize.headerRowHeight + currentSize.contentHeight + emptyRowHeight + scrollbarHeight);
|
|
34
|
+
}));
|
|
35
|
+
observer.observe(node, { attributes: true, attributeFilter: ["style"] });
|
|
36
|
+
return () => observer.disconnect();
|
|
37
|
+
}, [mounted, storedSize]);
|
|
38
|
+
return {
|
|
39
|
+
className: "uxf-data-grid__table rdg-light",
|
|
40
|
+
headerRowHeight,
|
|
41
|
+
ready: mounted,
|
|
42
|
+
ref,
|
|
43
|
+
rowHeight,
|
|
44
|
+
style: { height },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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.useReactDataGridColumns = useReactDataGridColumns;
|
|
27
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const react_data_grid_1 = require("react-data-grid");
|
|
30
|
+
function useReactDataGridColumns(props, state) {
|
|
31
|
+
const { reload, schema, isRowSelectable, bodyCells, actionCell } = props;
|
|
32
|
+
const userConfigColumns = state.userConfig.columns;
|
|
33
|
+
return (0, react_1.useMemo)(() => {
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
35
|
+
const columns = [];
|
|
36
|
+
if (isRowSelectable) {
|
|
37
|
+
columns.push(react_data_grid_1.SelectColumn);
|
|
38
|
+
}
|
|
39
|
+
for (const schemaColumn of schema.columns) {
|
|
40
|
+
if (schemaColumn.hidden) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const isHidden = (_b = (_a = userConfigColumns === null || userConfigColumns === void 0 ? void 0 : userConfigColumns[schemaColumn.name]) === null || _a === void 0 ? void 0 : _a.isHidden) !== null && _b !== void 0 ? _b : (_c = schemaColumn.config) === null || _c === void 0 ? void 0 : _c.isHidden;
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
45
|
+
if (isHidden) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
columns.push({
|
|
49
|
+
key: schemaColumn.name,
|
|
50
|
+
name: schemaColumn.label,
|
|
51
|
+
headerCellClass: (0, cx_1.cx)("uxf-data-grid__cell", "uxf-data-grid__cell--header", `uxf-data-grid__cell--type-${schemaColumn.type}`, `uxf-data-grid__cell--name-${schemaColumn.name}`),
|
|
52
|
+
resizable: true,
|
|
53
|
+
sortable: schemaColumn.sort,
|
|
54
|
+
width: (_f = (_e = (_d = state.userConfig.columns) === null || _d === void 0 ? void 0 : _d[schemaColumn.name]) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : (_g = schemaColumn.config) === null || _g === void 0 ? void 0 : _g.width,
|
|
55
|
+
minWidth: (_k = (_j = (_h = state.userConfig.columns) === null || _h === void 0 ? void 0 : _h[schemaColumn.name]) === null || _j === void 0 ? void 0 : _j.minWidth) !== null && _k !== void 0 ? _k : (_l = schemaColumn.config) === null || _l === void 0 ? void 0 : _l.minWidth,
|
|
56
|
+
cellClass: (0, cx_1.cx)("uxf-data-grid__cell", `uxf-data-grid__cell--type-${schemaColumn.type}`, `uxf-data-grid__cell--name-${schemaColumn.name}`),
|
|
57
|
+
renderCell: (p) => {
|
|
58
|
+
var _a;
|
|
59
|
+
const columnType = schemaColumn.type;
|
|
60
|
+
const BodyCell = (_a = bodyCells === null || bodyCells === void 0 ? void 0 : bodyCells[columnType]) !== null && _a !== void 0 ? _a : bodyCells === null || bodyCells === void 0 ? void 0 : bodyCells.default;
|
|
61
|
+
if (!BodyCell) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return (react_1.default.createElement(BodyCell, { column: {
|
|
65
|
+
name: p.column.key,
|
|
66
|
+
label: p.column.name,
|
|
67
|
+
sort: p.column.sortable,
|
|
68
|
+
type: columnType,
|
|
69
|
+
}, reload: reload, row: p.row, value: p.row[p.column.key] }));
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (actionCell) {
|
|
74
|
+
columns.push({
|
|
75
|
+
key: "__action_column",
|
|
76
|
+
name: "",
|
|
77
|
+
resizable: false,
|
|
78
|
+
headerCellClass: "uxf-data-grid__action-cell",
|
|
79
|
+
cellClass: "uxf-data-grid__action-cell",
|
|
80
|
+
width: actionCell.width,
|
|
81
|
+
renderCell: (p) => react_1.default.createElement(actionCell.Component, { reload: reload, row: p.row }),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return columns;
|
|
85
|
+
}, [userConfigColumns, actionCell, schema.columns, bodyCells, isRowSelectable, reload, state.userConfig.columns]);
|
|
86
|
+
}
|
package/table/index.d.ts
ADDED
package/table/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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("./components/action-cell"), exports);
|
|
18
|
+
__exportStar(require("./components/action-cell-wrapper"), exports);
|
|
19
|
+
__exportStar(require("./table"), 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-data-grid__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
|
+
}
|
package/table/table.d.ts
ADDED
package/table/table.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.DataGridTable = DataGridTable;
|
|
31
|
+
const show_1 = require("@uxf/core-react/components/show");
|
|
32
|
+
const use_is_mounted_1 = require("@uxf/core-react/hooks/use-is-mounted");
|
|
33
|
+
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
34
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
35
|
+
const react_1 = __importStar(require("react"));
|
|
36
|
+
const react_data_grid_1 = __importDefault(require("react-data-grid"));
|
|
37
|
+
const select_row_checkbox_1 = require("./components/select-row-checkbox");
|
|
38
|
+
const use_rdg_visuals_1 = require("./hooks/use-rdg-visuals");
|
|
39
|
+
const use_react_data_grid_columns_1 = require("./hooks/use-react-data-grid-columns");
|
|
40
|
+
const no_rows_fallback_1 = require("./no-rows-fallback");
|
|
41
|
+
const defaultKeyExtractor = (r) => r.id;
|
|
42
|
+
const DefaultNoRowsFallback = no_rows_fallback_1.NoRowsFallback;
|
|
43
|
+
/** @deprecated will be remove, use DataGridTableV2 */
|
|
44
|
+
function DataGridTable(props) {
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
46
|
+
const isMounted = (0, use_is_mounted_1.useIsMounted)();
|
|
47
|
+
const rowHeight = (_a = props.rowHeight) !== null && _a !== void 0 ? _a : 44;
|
|
48
|
+
const headerRowHeight = (_b = props.headerRowHeight) !== null && _b !== void 0 ? _b : 36;
|
|
49
|
+
const keyExtractor = (_c = props.keyExtractor) !== null && _c !== void 0 ? _c : defaultKeyExtractor;
|
|
50
|
+
const contentHeight = typeof rowHeight === "function"
|
|
51
|
+
? props.data.reduce((prev, curr) => prev + rowHeight(curr))
|
|
52
|
+
: (rowHeight + 1) * props.data.length;
|
|
53
|
+
const reactDataGridStyles = {
|
|
54
|
+
height: contentHeight + headerRowHeight + (props.data.length === 0 ? 44 : 0) + 4,
|
|
55
|
+
overflowY: "hidden",
|
|
56
|
+
};
|
|
57
|
+
const NoRowsFallback = (_d = props.NoRowsFallback) !== null && _d !== void 0 ? _d : DefaultNoRowsFallback;
|
|
58
|
+
const isLoading = Boolean(props.isLoading);
|
|
59
|
+
const error = props.error;
|
|
60
|
+
const components = (0, react_1.useMemo)(() => ({
|
|
61
|
+
renderCheckbox: (args) => react_1.default.createElement(select_row_checkbox_1.SelectRowCheckbox, { ...args }),
|
|
62
|
+
noRowsFallback: react_1.default.createElement(NoRowsFallback, { error: error, isLoading: isLoading }),
|
|
63
|
+
}), [NoRowsFallback, error, isLoading]);
|
|
64
|
+
const columns = (0, use_react_data_grid_columns_1.useReactDataGridColumns)(props, props.state);
|
|
65
|
+
const onSelectRows = (value) => {
|
|
66
|
+
const selectedRows = Array.from(value).map((id) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
return (_b = (_a = props.state.selectedRows) === null || _a === void 0 ? void 0 : _a.find((row) => keyExtractor(row) === id)) !== null && _b !== void 0 ? _b : props.data.find((row) => keyExtractor(row) === id);
|
|
69
|
+
});
|
|
70
|
+
props.actions.setSelectedRows(selectedRows);
|
|
71
|
+
};
|
|
72
|
+
const onSortColumnChange = (sortColumns) => {
|
|
73
|
+
const firstSortColumn = sortColumns.at(0);
|
|
74
|
+
if ((0, is_not_nil_1.isNotNil)(firstSortColumn)) {
|
|
75
|
+
props.actions.sort(firstSortColumn.columnKey, firstSortColumn.direction.toLowerCase());
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
props.actions.sortClear();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const sortColumns = props.state.request.s
|
|
82
|
+
? [{ columnKey: props.state.request.s.name, direction: props.state.request.s.dir.toUpperCase() }]
|
|
83
|
+
: empty_array_1.EMPTY_ARRAY;
|
|
84
|
+
const rdgVisuals = (0, use_rdg_visuals_1.useRdgVisuals)({
|
|
85
|
+
headerRowHeight: props.headerRowHeight,
|
|
86
|
+
rowHeight: props.rowHeight,
|
|
87
|
+
rows: props.data,
|
|
88
|
+
});
|
|
89
|
+
return (react_1.default.createElement(show_1.Show, { when: isMounted },
|
|
90
|
+
react_1.default.createElement(react_data_grid_1.default, { className: rdgVisuals.className, columns: columns, enableVirtualization: false, headerRowHeight: rdgVisuals.headerRowHeight, onSelectedRowsChange: onSelectRows, onSortColumnsChange: onSortColumnChange, ref: rdgVisuals.ref, renderers: components, rowClass: props.rowClass, rowHeight: rdgVisuals.rowHeight, rowKeyGetter: (_e = props.keyExtractor) !== null && _e !== void 0 ? _e : defaultKeyExtractor, rows: props.data, selectedRows: new Set((_g = (_f = props.state.selectedRows) === null || _f === void 0 ? void 0 : _f.map(keyExtractor)) !== null && _g !== void 0 ? _g : empty_array_1.EMPTY_ARRAY), sortColumns: sortColumns, style: reactDataGridStyles })));
|
|
91
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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.Default = Default;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const data_1 = require("../_story-utils/data");
|
|
9
|
+
const json_renderer_1 = require("../_story-utils/json-renderer");
|
|
10
|
+
const schema_1 = require("../_story-utils/schema");
|
|
11
|
+
const body_cell_1 = require("../body-cell");
|
|
12
|
+
const use_data_grid_control_1 = require("../use-data-grid-control");
|
|
13
|
+
const table_1 = require("./table");
|
|
14
|
+
function Default() {
|
|
15
|
+
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
|
|
16
|
+
const reload = () => new Promise(() => null);
|
|
17
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
18
|
+
react_1.default.createElement(table_1.DataGridTable, { actions: actions, bodyCells: body_cell_1.BodyCells, data: data_1.data, error: undefined, isLoading: true, isRowSelectable: true, reload: reload, schema: schema_1.schema, state: state }),
|
|
19
|
+
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
20
|
+
}
|