@uxf/data-grid 10.0.7 → 11.0.0-beta.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/_store/reducer.d.ts +8 -0
- package/{store → _store}/reducer.js +33 -19
- package/_story-utils/data.d.ts +12 -0
- package/_story-utils/data.js +115 -0
- package/_story-utils/grid-type.d.ts +22 -0
- package/_story-utils/grid-type.js +2 -0
- package/_story-utils/loader.d.ts +2 -0
- package/_story-utils/loader.js +36 -0
- package/_story-utils/schema.d.ts +3 -0
- package/_story-utils/schema.js +53 -0
- package/{tailwindui/body-cell → body-cell}/body-cell-boolean.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-date.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-datetime.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-default.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-email.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-phone.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-to-many.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-to-one.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-url.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/index.d.ts +1 -1
- package/data-grid.d.ts +1 -1
- package/data-grid.js +34 -120
- package/data-grid.stories.d.ts +0 -5
- package/data-grid.stories.js +14 -216
- package/export-button/export-button.d.ts +10 -0
- package/export-button/export-button.js +15 -0
- package/export-button/export-button.stories.d.ts +2 -0
- package/export-button/export-button.stories.js +18 -0
- package/export-button/index.d.ts +1 -0
- package/{tailwindui → export-button}/index.js +1 -3
- package/{tailwindui/filter-handler → filter-handler}/bool-filter.d.ts +1 -1
- package/{tailwindui/filter-handler → filter-handler}/boolean-filter.d.ts +1 -1
- package/filter-handler/index.d.ts +4 -0
- package/{tailwindui/filter-handler → filter-handler}/index.js +15 -0
- package/{tailwindui/filter-handler → filter-handler}/interval-filter.d.ts +1 -1
- package/{tailwindui/filter-handler → filter-handler}/interval-filter.js +2 -2
- package/{tailwindui/filter-handler → filter-handler}/select-filter.d.ts +1 -1
- package/{tailwindui/filter-handler → filter-handler}/text-filter.d.ts +1 -1
- package/filter-handler/types.d.ts +8 -0
- package/filter-handler/types.js +2 -0
- package/filter-list/filter-list.d.ts +11 -0
- package/{tailwindui/components → filter-list}/filter-list.js +7 -6
- package/filter-list/filter-list.stories.d.ts +2 -0
- package/filter-list/filter-list.stories.js +19 -0
- package/filter-list/index.d.ts +1 -0
- package/filter-list/index.js +17 -0
- package/filters/filters.d.ts +11 -0
- package/filters/filters.js +25 -0
- package/filters/filters.stories.d.ts +2 -0
- package/filters/filters.stories.js +19 -0
- package/filters/index.d.ts +1 -0
- package/filters/index.js +17 -0
- package/filters-button/filters-button.d.ts +11 -0
- package/{tailwindui/show.js → filters-button/filters-button.js} +15 -6
- package/filters-button/filters-button.stories.d.ts +2 -0
- package/filters-button/filters-button.stories.js +19 -0
- package/filters-button/index.d.ts +1 -0
- package/filters-button/index.js +17 -0
- package/fulltext-input/fulltext-input.d.ts +5 -0
- package/fulltext-input/fulltext-input.js +13 -0
- package/fulltext-input/fulltext-input.stories.d.ts +2 -0
- package/fulltext-input/fulltext-input.stories.js +18 -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 +17 -0
- package/hidden-columns/hidden-columns.stories.d.ts +2 -0
- package/hidden-columns/hidden-columns.stories.js +18 -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/{tailwindui/data-grid.js → hidden-columns-button/hidden-columns-button.js} +14 -10
- package/hidden-columns-button/hidden-columns-button.stories.d.ts +2 -0
- package/hidden-columns-button/hidden-columns-button.stories.js +18 -0
- package/hidden-columns-button/index.d.ts +1 -0
- package/hidden-columns-button/index.js +17 -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/{tailwindui/components → linear-progress}/linear-progress.js +4 -4
- package/package.json +1 -1
- package/pagination/index.d.ts +1 -0
- package/pagination/index.js +17 -0
- package/pagination/pagination.d.ts +8 -0
- package/pagination/pagination.js +16 -0
- package/pagination/pagination.stories.d.ts +2 -0
- package/pagination/pagination.stories.js +18 -0
- package/row-counts/index.d.ts +1 -0
- package/row-counts/index.js +17 -0
- package/row-counts/row-counts.d.ts +7 -0
- package/row-counts/row-counts.js +18 -0
- package/row-counts/row-counts.stories.d.ts +2 -0
- package/row-counts/row-counts.stories.js +15 -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/{tailwindui/components/pagination-rows-per-page-select.js → rows-per-page-select/rows-per-page-select.js} +5 -5
- 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 +18 -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/{tailwindui/components → selected-rows-toolbar}/selected-rows-toolbar.js +9 -6
- package/selected-rows-toolbar/selected-rows-toolbar.stories.d.ts +2 -0
- package/{tailwindui/components/select-row-checkbox.js → selected-rows-toolbar/selected-rows-toolbar.stories.js} +15 -14
- package/table/components/select-row-checkbox.d.ts +3 -0
- package/table/components/select-row-checkbox.js +20 -0
- package/table/hooks/use-react-data-grid-columns.d.ts +3 -0
- package/table/hooks/use-react-data-grid-columns.js +92 -0
- package/table/index.d.ts +1 -0
- package/table/index.js +17 -0
- package/table/no-rows-fallback.d.ts +7 -0
- package/{tailwindui/components → table}/no-rows-fallback.js +4 -4
- package/table/table.d.ts +3 -0
- package/table/table.js +80 -0
- package/table/table.stories.d.ts +2 -0
- package/table/table.stories.js +20 -0
- package/table/types.d.ts +26 -0
- package/table/types.js +2 -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 +20 -0
- package/toolbar-customs/index.d.ts +1 -0
- package/toolbar-customs/index.js +17 -0
- package/toolbar-customs/toolbar-customs.d.ts +10 -0
- package/{tailwindui/components → toolbar-customs}/toolbar-customs.js +2 -2
- package/toolbar-customs/toolbar-customs.stories.d.ts +2 -0
- package/toolbar-customs/toolbar-customs.stories.js +16 -0
- package/toolbar-tabs/index.d.ts +1 -0
- package/toolbar-tabs/index.js +17 -0
- package/toolbar-tabs/toolbar-tabs.d.ts +7 -0
- package/{tailwindui/components → toolbar-tabs}/toolbar-tabs.js +10 -10
- package/toolbar-tabs/toolbar-tabs.stories.d.ts +2 -0
- package/toolbar-tabs/toolbar-tabs.stories.js +18 -0
- package/types/components.d.ts +5 -160
- package/types/data-grid-props.d.ts +16 -23
- package/types/state.d.ts +7 -3
- package/types/ui-components.d.ts +7 -16
- package/use-data-grid-control/actions-factory.d.ts +14 -0
- package/use-data-grid-control/actions-factory.js +18 -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 +25 -0
- package/use-data-grid-control/use-data-grid-control.js +12 -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/use-data-grid-fetching.d.ts +16 -0
- package/use-data-grid-fetching/use-data-grid-fetching.js +37 -0
- package/utils/classes.d.ts +1 -0
- package/utils/classes.js +4 -0
- package/utils.d.ts +4 -5
- package/utils.js +9 -60
- package/hooks/useColumns.d.ts +0 -3
- package/hooks/useColumns.js +0 -97
- package/store/reducer.d.ts +0 -5
- package/tailwindui/components/container.d.ts +0 -2
- package/tailwindui/components/container.js +0 -13
- package/tailwindui/components/filter-list.d.ts +0 -2
- package/tailwindui/components/footer.d.ts +0 -2
- package/tailwindui/components/footer.js +0 -12
- package/tailwindui/components/linear-progress.d.ts +0 -2
- package/tailwindui/components/no-rows-fallback.d.ts +0 -2
- package/tailwindui/components/pagination-counts.d.ts +0 -2
- package/tailwindui/components/pagination-counts.js +0 -18
- package/tailwindui/components/pagination-rows-per-page-select.d.ts +0 -2
- package/tailwindui/components/select-row-checkbox.d.ts +0 -2
- package/tailwindui/components/selected-rows-toolbar.d.ts +0 -2
- package/tailwindui/components/toolbar-control.d.ts +0 -2
- package/tailwindui/components/toolbar-control.js +0 -86
- package/tailwindui/components/toolbar-customs.d.ts +0 -2
- package/tailwindui/components/toolbar-tabs.d.ts +0 -2
- package/tailwindui/components/toolbar.d.ts +0 -2
- package/tailwindui/components/toolbar.js +0 -12
- package/tailwindui/data-grid.d.ts +0 -6
- package/tailwindui/filter-handler/index.d.ts +0 -2
- package/tailwindui/index.d.ts +0 -3
- package/tailwindui/show.d.ts +0 -7
- package/tailwindui/styles.css +0 -592
- package/tailwindui/ui.d.ts +0 -2
- package/tailwindui/ui.js +0 -38
- /package/{tailwindui/components → _components}/drawer.d.ts +0 -0
- /package/{tailwindui/components → _components}/drawer.js +0 -0
- /package/{store → _store}/actions.d.ts +0 -0
- /package/{store → _store}/actions.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-boolean.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-date.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-datetime.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-default.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-email.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-phone.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-to-many.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-to-one.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-url.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/index.js +0 -0
- /package/{tailwindui/filter-handler → filter-handler}/bool-filter.js +0 -0
- /package/{tailwindui/filter-handler → filter-handler}/boolean-filter.js +0 -0
- /package/{tailwindui/filter-handler → filter-handler}/select-filter.js +0 -0
- /package/{tailwindui/filter-handler → filter-handler}/text-filter.js +0 -0
- /package/{tailwindui → table}/components/action-cell-base.d.ts +0 -0
- /package/{tailwindui → table}/components/action-cell-base.js +0 -0
package/types/components.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { RequestFilter, Response } from "./api";
|
|
5
|
-
import { ChangeHiddenColumnsHandler, CsvDownloadHandler } from "./core";
|
|
6
|
-
import { BaseGridType, Columns, Filter, Filters, Schema } from "./schema";
|
|
7
|
-
import { DataGridState } from "./state";
|
|
8
|
-
/**
|
|
9
|
-
* Action cell
|
|
10
|
-
*/
|
|
1
|
+
import { ComponentType, FC } from "react";
|
|
2
|
+
import { RequestFilter } from "./api";
|
|
3
|
+
import { BaseGridType, Columns, Filter } from "./schema";
|
|
11
4
|
export interface ActionCellProps<R> {
|
|
12
5
|
row: R;
|
|
13
6
|
onOpen?: (row: R) => void;
|
|
@@ -15,47 +8,20 @@ export interface ActionCellProps<R> {
|
|
|
15
8
|
onEdit?: (row: R) => void;
|
|
16
9
|
getEditUrl?: (row: R) => string | null | undefined;
|
|
17
10
|
onRemove?: (row: R, reload: () => void) => void;
|
|
18
|
-
reload: () =>
|
|
11
|
+
reload: () => void;
|
|
19
12
|
}
|
|
20
13
|
export type ActionCellComponent<R> = FC<ActionCellProps<R>>;
|
|
21
|
-
/**
|
|
22
|
-
* Body cell
|
|
23
|
-
*/
|
|
24
14
|
export interface BodyCellProps<C, R> {
|
|
25
15
|
value: any;
|
|
26
16
|
column: C;
|
|
27
17
|
row: R;
|
|
28
|
-
reload: () =>
|
|
18
|
+
reload: () => void;
|
|
29
19
|
}
|
|
30
20
|
export type BodyCellComponent<C extends BaseGridType["columns"], R> = ComponentType<BodyCellProps<Columns<C>, R>>;
|
|
31
21
|
export type BodyCellComponents<C, R> = {
|
|
32
22
|
[key: string]: BodyCellComponent<C, R>;
|
|
33
23
|
default: BodyCellComponent<C, R>;
|
|
34
24
|
};
|
|
35
|
-
/**
|
|
36
|
-
* Container
|
|
37
|
-
*/
|
|
38
|
-
export interface ContainerProps {
|
|
39
|
-
noBorder?: boolean;
|
|
40
|
-
children: ReactNode;
|
|
41
|
-
className?: string;
|
|
42
|
-
}
|
|
43
|
-
export type ContainerComponent = FC<ContainerProps>;
|
|
44
|
-
/**
|
|
45
|
-
* Filter list
|
|
46
|
-
*/
|
|
47
|
-
export interface FilterListProps<F extends Filter<any, any>, T> {
|
|
48
|
-
gridName?: string;
|
|
49
|
-
filters: F[];
|
|
50
|
-
filtersData: RequestFilter<T>[];
|
|
51
|
-
onFilter: (value: RequestFilter<T>) => void;
|
|
52
|
-
filterHandlers: FilterHandlers;
|
|
53
|
-
noBorder: boolean | null | undefined;
|
|
54
|
-
}
|
|
55
|
-
export type FilterListComponent<F extends BaseGridType["filters"], T = any> = ComponentType<FilterListProps<Filters<F>, T>>;
|
|
56
|
-
/**
|
|
57
|
-
* Filters
|
|
58
|
-
*/
|
|
59
25
|
export interface FilterProps<F extends Filter<any, any>, T> {
|
|
60
26
|
gridName?: string;
|
|
61
27
|
filter: F;
|
|
@@ -63,124 +29,3 @@ export interface FilterProps<F extends Filter<any, any>, T> {
|
|
|
63
29
|
onFilter: (value: RequestFilter<T>) => void;
|
|
64
30
|
onClear: () => void;
|
|
65
31
|
}
|
|
66
|
-
export type FilterComponent<F extends BaseGridType["filters"], T = any> = ComponentType<FilterProps<Filters<F>, T>>;
|
|
67
|
-
export interface FilterHandler {
|
|
68
|
-
input: FilterComponent<any>;
|
|
69
|
-
listItem: FilterComponent<any>;
|
|
70
|
-
}
|
|
71
|
-
export interface FilterHandlers {
|
|
72
|
-
[key: string]: FilterHandler;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Footer
|
|
76
|
-
*/
|
|
77
|
-
export interface FooterProps {
|
|
78
|
-
children: ReactNode;
|
|
79
|
-
noBorder?: boolean;
|
|
80
|
-
}
|
|
81
|
-
export type FooterComponent = FC<FooterProps>;
|
|
82
|
-
/**
|
|
83
|
-
* Linear progress
|
|
84
|
-
*/
|
|
85
|
-
export interface LinearProgressProps {
|
|
86
|
-
loading: boolean;
|
|
87
|
-
}
|
|
88
|
-
export type LinearProgressComponent = FC<LinearProgressProps>;
|
|
89
|
-
/**
|
|
90
|
-
* No rows fallback
|
|
91
|
-
*/
|
|
92
|
-
export interface NoRowsFallbackProps {
|
|
93
|
-
error?: any;
|
|
94
|
-
loading: boolean;
|
|
95
|
-
}
|
|
96
|
-
export type NoRowsFallbackComponent = React.FC<NoRowsFallbackProps>;
|
|
97
|
-
/**
|
|
98
|
-
* Pagination
|
|
99
|
-
*/
|
|
100
|
-
export type PaginationComponent = React.FC<PaginationProps>;
|
|
101
|
-
/**
|
|
102
|
-
* Pagination rows per page select
|
|
103
|
-
*/
|
|
104
|
-
export interface PaginationRowsPerPageSelectProps {
|
|
105
|
-
value: number;
|
|
106
|
-
onChange: (value: number) => void;
|
|
107
|
-
}
|
|
108
|
-
export type PaginationRowsPerPageSelectComponent = FC<PaginationRowsPerPageSelectProps>;
|
|
109
|
-
/**
|
|
110
|
-
* Pagination counts
|
|
111
|
-
*/
|
|
112
|
-
export interface PaginationCountsProps {
|
|
113
|
-
page: number;
|
|
114
|
-
perPage: number;
|
|
115
|
-
response?: Response;
|
|
116
|
-
}
|
|
117
|
-
export type PaginationCountsComponent = FC<PaginationCountsProps>;
|
|
118
|
-
/**
|
|
119
|
-
* Selected rows toolbar
|
|
120
|
-
*/
|
|
121
|
-
export interface SelectedRowsToolbarProps {
|
|
122
|
-
selectedRows?: Set<number>;
|
|
123
|
-
onChangeSelectedRows?: (rows: Set<number>) => void;
|
|
124
|
-
Actions?: SelectedRowsToolbarActionsComponent;
|
|
125
|
-
reload: () => Promise<void>;
|
|
126
|
-
}
|
|
127
|
-
export type SelectedRowsToolbarComponent = FC<SelectedRowsToolbarProps>;
|
|
128
|
-
/**
|
|
129
|
-
* Select row checkbox
|
|
130
|
-
*/
|
|
131
|
-
export type SelectRowCheckboxComponent = React.FC<RenderCheckboxProps>;
|
|
132
|
-
/**
|
|
133
|
-
* Selected rows toolbar actions
|
|
134
|
-
*/
|
|
135
|
-
export interface SelectedRowsToolbarActionsProps {
|
|
136
|
-
selectedRows: Set<number>;
|
|
137
|
-
onChangeSelectedRows: (rows: Set<number>) => void;
|
|
138
|
-
reload: () => Promise<void>;
|
|
139
|
-
}
|
|
140
|
-
export type SelectedRowsToolbarActionsComponent = FC<SelectedRowsToolbarActionsProps>;
|
|
141
|
-
/**
|
|
142
|
-
* Toolbar
|
|
143
|
-
*/
|
|
144
|
-
export interface ToolbarProps {
|
|
145
|
-
children: ReactNode;
|
|
146
|
-
noBorder?: boolean;
|
|
147
|
-
}
|
|
148
|
-
export type ToolbarComponent = FC<ToolbarProps>;
|
|
149
|
-
/**
|
|
150
|
-
* Toolbar control
|
|
151
|
-
*/
|
|
152
|
-
export interface ToolbarControlProps {
|
|
153
|
-
gridName: string | undefined;
|
|
154
|
-
schema: Schema<any>;
|
|
155
|
-
dispatch: (action: any) => void;
|
|
156
|
-
filterHandlers: FilterHandlers;
|
|
157
|
-
onFulltextChange: (value: string) => void;
|
|
158
|
-
noBorder: boolean | null | undefined;
|
|
159
|
-
onChangeHiddenColumns?: ChangeHiddenColumnsHandler;
|
|
160
|
-
onCsvDownload?: CsvDownloadHandler;
|
|
161
|
-
hiddenColumns?: string[];
|
|
162
|
-
showFulltext?: boolean;
|
|
163
|
-
state: DataGridState;
|
|
164
|
-
}
|
|
165
|
-
export type ToolbarControlComponent = React.FC<ToolbarControlProps>;
|
|
166
|
-
/**
|
|
167
|
-
* Toolbar customs
|
|
168
|
-
*/
|
|
169
|
-
export interface ToolbarCustomsProps {
|
|
170
|
-
buttons?: {
|
|
171
|
-
label: string | ReactElement;
|
|
172
|
-
onClick?: () => void;
|
|
173
|
-
href?: string;
|
|
174
|
-
variant?: "default" | "outlined" | "text";
|
|
175
|
-
}[];
|
|
176
|
-
}
|
|
177
|
-
export type ToolbarCustomsComponent = React.FC<ToolbarCustomsProps>;
|
|
178
|
-
/**
|
|
179
|
-
* Toolbar tabs
|
|
180
|
-
*/
|
|
181
|
-
export interface ToolbarTabsProps {
|
|
182
|
-
activeTab: string | null;
|
|
183
|
-
onChange: (tabName: string) => void;
|
|
184
|
-
schema: Schema<any>;
|
|
185
|
-
}
|
|
186
|
-
export type ToolbarTabsComponent = React.FC<ToolbarTabsProps>;
|
|
@@ -1,38 +1,31 @@
|
|
|
1
|
-
import { MutableRefObject, ReactNode } from "react";
|
|
2
1
|
import { DataGridProps as RDGProps } from "react-data-grid";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { ToolbarCustomsProps } from "../toolbar-customs";
|
|
3
|
+
import { DataGridControl } from "../use-data-grid-control";
|
|
4
|
+
import { DataGridFetchingResult } from "../use-data-grid-fetching";
|
|
5
|
+
import { CsvDownloadHandler, KeyExtractor } from "./core";
|
|
6
6
|
import { BaseGridType, Schema } from "./schema";
|
|
7
7
|
import { UIComponents } from "./ui-components";
|
|
8
|
-
export type
|
|
9
|
-
|
|
8
|
+
export type DataGridControlProps = DataGridControl;
|
|
9
|
+
export type DataGridDataProps<Row> = DataGridFetchingResult<Row>;
|
|
10
|
+
export type DataGridBaseProps<GridType extends BaseGridType, Row> = {
|
|
10
11
|
schema: Schema<GridType>;
|
|
11
|
-
loader: Loader;
|
|
12
12
|
gridName?: string;
|
|
13
|
-
title?: ReactNode;
|
|
14
13
|
keyExtractor?: KeyExtractor;
|
|
15
|
-
initialState?: Request | string;
|
|
16
|
-
onChangeHiddenColumns?: ChangeHiddenColumnsHandler;
|
|
17
14
|
onCsvDownload?: CsvDownloadHandler;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
onEdit?: (row: R) => void;
|
|
24
|
-
getEditUrl?: (row: R) => string | null | undefined;
|
|
25
|
-
onRemove?: (row: R, reload: () => void) => void;
|
|
15
|
+
onOpen?: (row: Row) => void;
|
|
16
|
+
getOpenUrl?: (row: Row) => string | null | undefined;
|
|
17
|
+
onEdit?: (row: Row) => void;
|
|
18
|
+
getEditUrl?: (row: Row) => string | null | undefined;
|
|
19
|
+
onRemove?: (row: Row, reload: () => void) => void;
|
|
26
20
|
noBorder?: boolean;
|
|
27
21
|
rowHeight?: RDGProps<any>["rowHeight"];
|
|
28
22
|
headerRowHeight?: RDGProps<any>["headerRowHeight"];
|
|
29
|
-
|
|
30
|
-
rowClass?: (row: R) => "success" | "warning" | "error" | "primary" | "secondary" | string | null | undefined;
|
|
23
|
+
rowClass?: (row: Row) => "success" | "warning" | "error" | "primary" | "secondary" | string | null | undefined;
|
|
31
24
|
debug?: boolean;
|
|
32
25
|
className?: string;
|
|
33
26
|
customActions?: ToolbarCustomsProps["buttons"];
|
|
34
27
|
mode?: "light" | "dark";
|
|
28
|
+
ui?: UIComponents<GridType, Row>;
|
|
29
|
+
isRowSelectable?: boolean;
|
|
35
30
|
};
|
|
36
|
-
export type DataGridProps<GridType extends BaseGridType,
|
|
37
|
-
ui: UIComponents<GridType, R>;
|
|
38
|
-
};
|
|
31
|
+
export type DataGridProps<GridType extends BaseGridType, Row> = DataGridBaseProps<GridType, Row> & DataGridDataProps<Row> & DataGridControlProps;
|
package/types/state.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestFilter, Response } from "./api";
|
|
2
2
|
import { DataGridSortDir } from "./schema";
|
|
3
|
-
type GridRequest = {
|
|
3
|
+
export type GridRequest = {
|
|
4
4
|
f: RequestFilter[];
|
|
5
5
|
sort: string | null;
|
|
6
6
|
dir: DataGridSortDir | null;
|
|
@@ -9,11 +9,15 @@ type GridRequest = {
|
|
|
9
9
|
search: string;
|
|
10
10
|
tab: string | null;
|
|
11
11
|
};
|
|
12
|
+
interface ColumnConfig {
|
|
13
|
+
isHidden: boolean;
|
|
14
|
+
width?: number;
|
|
15
|
+
}
|
|
12
16
|
export interface DataGridState {
|
|
13
|
-
loading?: boolean;
|
|
14
17
|
response?: Response;
|
|
15
18
|
request: GridRequest;
|
|
16
|
-
|
|
19
|
+
selectedRows?: any[];
|
|
20
|
+
columnConfig: Record<string, ColumnConfig>;
|
|
17
21
|
tabRequests: {
|
|
18
22
|
[tab: string]: GridRequest;
|
|
19
23
|
};
|
package/types/ui-components.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FilterHandlers } from "../filter-handler";
|
|
2
|
+
import { SelectedRowsToolbarActionsComponent } from "../selected-rows-toolbar";
|
|
3
|
+
import { NoRowsFallbackComponent } from "../table/no-rows-fallback";
|
|
4
|
+
import { ActionCellComponent, BodyCellComponents } from "./components";
|
|
2
5
|
import { BaseGridType } from "./schema";
|
|
3
6
|
export type ActionCellWithRequiredWidth<R> = {
|
|
4
7
|
ActionCell?: ActionCellComponent<R>;
|
|
@@ -8,20 +11,8 @@ export type ActionCellWithRequiredWidth<R> = {
|
|
|
8
11
|
actionCellWidth?: never;
|
|
9
12
|
};
|
|
10
13
|
export type UIComponents<GridType extends BaseGridType, R> = {
|
|
11
|
-
BodyCells
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
FilterList: FilterListComponent<GridType["filters"], R>;
|
|
15
|
-
LinearProgress: LinearProgressComponent;
|
|
16
|
-
NoRowsFallback: NoRowsFallbackComponent;
|
|
17
|
-
Pagination: PaginationComponent;
|
|
18
|
-
PaginationCounts: PaginationCountsComponent;
|
|
19
|
-
PaginationRowsPerPageSelect: PaginationRowsPerPageSelectComponent;
|
|
20
|
-
SelectRowCheckbox: SelectRowCheckboxComponent;
|
|
21
|
-
SelectedRowsToolbar: SelectedRowsToolbarComponent;
|
|
14
|
+
BodyCells?: BodyCellComponents<GridType["columns"], R>;
|
|
15
|
+
FilterHandlers?: FilterHandlers;
|
|
16
|
+
NoRowsFallback?: NoRowsFallbackComponent;
|
|
22
17
|
SelectedRowsToolbarActions?: SelectedRowsToolbarActionsComponent;
|
|
23
|
-
Toolbar: ToolbarComponent;
|
|
24
|
-
ToolbarControl: ToolbarControlComponent;
|
|
25
|
-
ToolbarCustoms: ToolbarCustomsComponent;
|
|
26
|
-
ToolbarTabs: ToolbarTabsComponent;
|
|
27
18
|
} & ActionCellWithRequiredWidth<R>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Dispatch } from "react";
|
|
2
|
+
import { RequestFilter } from "../types/api";
|
|
3
|
+
export declare function createActions(dispatch: Dispatch<any>): {
|
|
4
|
+
changePage: (page: number) => void;
|
|
5
|
+
changePerPage: (perPage: number) => void;
|
|
6
|
+
filter: (filterValue: RequestFilter) => void;
|
|
7
|
+
sort: (columnName: string, direction: string) => void;
|
|
8
|
+
sortClear: () => void;
|
|
9
|
+
search: (search: string) => void;
|
|
10
|
+
changeTab: (tabName: string) => void;
|
|
11
|
+
setSelectedRows: (rows: any[]) => void;
|
|
12
|
+
hideColumn: (name: string) => void;
|
|
13
|
+
showColumn: (name: string) => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createActions = void 0;
|
|
4
|
+
function createActions(dispatch) {
|
|
5
|
+
return {
|
|
6
|
+
changePage: (page) => dispatch({ type: "CHANGE_PAGE", page }),
|
|
7
|
+
changePerPage: (perPage) => dispatch({ type: "CHANGE_PER_PAGE", perPage }),
|
|
8
|
+
filter: (filterValue) => dispatch({ type: "FILTER", filterValue }),
|
|
9
|
+
sort: (columnName, direction) => dispatch({ type: "SORT", columnName, direction }),
|
|
10
|
+
sortClear: () => dispatch({ type: "SORT_CLEAR" }),
|
|
11
|
+
search: (search) => dispatch({ type: "FULLTEXT", search }),
|
|
12
|
+
changeTab: (tabName) => dispatch({ type: "CHANGE_TAB", name: tabName }),
|
|
13
|
+
setSelectedRows: (rows) => dispatch({ type: "SET_SELECTED_ROWS", rows }),
|
|
14
|
+
hideColumn: (name) => dispatch({ type: "HIDE_COLUMN", name }),
|
|
15
|
+
showColumn: (name) => dispatch({ type: "SHOW_COLUMN", name }),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.createActions = createActions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./use-data-grid-control";
|
|
@@ -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("./use-data-grid-control"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Nullish } from "@uxf/core/types";
|
|
2
|
+
import { Request } from "../types/api";
|
|
3
|
+
import { Schema } from "../types/schema";
|
|
4
|
+
interface Config {
|
|
5
|
+
schema: Schema<any>;
|
|
6
|
+
initialState?: Request | string | Nullish;
|
|
7
|
+
isDebug?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useDataGridControl(config: Config): {
|
|
10
|
+
state: import("..").DataGridState;
|
|
11
|
+
actions: {
|
|
12
|
+
changePage: (page: number) => void;
|
|
13
|
+
changePerPage: (perPage: number) => void;
|
|
14
|
+
filter: (filterValue: import("../types/api").RequestFilter<any>) => void;
|
|
15
|
+
sort: (columnName: string, direction: string) => void;
|
|
16
|
+
sortClear: () => void;
|
|
17
|
+
search: (search: string) => void;
|
|
18
|
+
changeTab: (tabName: string) => void;
|
|
19
|
+
setSelectedRows: (rows: any[]) => void;
|
|
20
|
+
hideColumn: (name: string) => void;
|
|
21
|
+
showColumn: (name: string) => void;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type DataGridControl = ReturnType<typeof useDataGridControl>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDataGridControl = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const reducer_1 = require("../_store/reducer");
|
|
6
|
+
const actions_factory_1 = require("./actions-factory");
|
|
7
|
+
function useDataGridControl(config) {
|
|
8
|
+
const [state, dispatch] = (0, react_1.useReducer)(config.isDebug ? reducer_1.debugReducer : reducer_1.reducer, (0, reducer_1.getInitialState)(config.schema, config.initialState));
|
|
9
|
+
const actions = (0, react_1.useMemo)(() => (0, actions_factory_1.createActions)(dispatch), [dispatch]);
|
|
10
|
+
return { state, actions };
|
|
11
|
+
}
|
|
12
|
+
exports.useDataGridControl = useDataGridControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./use-data-grid-fetching";
|
|
@@ -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("./use-data-grid-fetching"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Loader } from "../types/core";
|
|
2
|
+
import { Schema } from "../types/schema";
|
|
3
|
+
import { DataGridControl } from "../use-data-grid-control";
|
|
4
|
+
interface Response<Row> {
|
|
5
|
+
result: Row[];
|
|
6
|
+
count: number;
|
|
7
|
+
totalCount: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DataGridFetchingResult<Row> {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error?: any;
|
|
12
|
+
data: Response<Row> | null;
|
|
13
|
+
onReload: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function useDataGridFetching(loader: Loader, schema: Schema<any>, gridName: string, state: DataGridControl["state"]): DataGridFetchingResult<any>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDataGridFetching = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
function useDataGridFetching(loader, schema, gridName, state) {
|
|
7
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
8
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
9
|
+
const [data, setData] = (0, react_1.useState)(null);
|
|
10
|
+
const stringStateRequest = JSON.stringify(state.request);
|
|
11
|
+
const reload = (0, react_1.useCallback)(() => {
|
|
12
|
+
const stateRequest = JSON.parse(stringStateRequest);
|
|
13
|
+
const request = (0, utils_1.createRequest)(stateRequest, schema.sort, schema.dir);
|
|
14
|
+
loader(gridName, request, (0, utils_1.encodeFilter)(request))
|
|
15
|
+
.then((response) => {
|
|
16
|
+
setData(response);
|
|
17
|
+
setError(null);
|
|
18
|
+
setIsLoading(false);
|
|
19
|
+
})
|
|
20
|
+
.catch((e) => {
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.error(e);
|
|
23
|
+
setIsLoading(false);
|
|
24
|
+
setError(e);
|
|
25
|
+
});
|
|
26
|
+
}, [stringStateRequest, schema.dir, schema.sort, loader, gridName]);
|
|
27
|
+
(0, react_1.useEffect)(() => {
|
|
28
|
+
reload();
|
|
29
|
+
}, [reload]);
|
|
30
|
+
return {
|
|
31
|
+
data,
|
|
32
|
+
isLoading,
|
|
33
|
+
error,
|
|
34
|
+
onReload: reload,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.useDataGridFetching = useDataGridFetching;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NO_BORDER_CLASS = "no-border";
|
package/utils/classes.js
ADDED
package/utils.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Request } from "./types/api";
|
|
2
|
+
import { DataGridSortDir } from "./types/schema";
|
|
3
|
+
import { GridRequest } from "./types/state";
|
|
2
4
|
export declare function decodeFilter(filterString: string): null | Request;
|
|
3
5
|
export declare function encodeFilter(request: Request): string;
|
|
4
|
-
export declare function createRequest(
|
|
5
|
-
export type ClassArray = ClassValue[];
|
|
6
|
-
export type ClassValue = ClassArray | Record<string, any> | string | number | null | boolean | undefined;
|
|
7
|
-
export declare function cx(...classes: ClassValue[]): string;
|
|
6
|
+
export declare function createRequest(request: GridRequest, defaultSort: string, defaultDir: DataGridSortDir): Request;
|
package/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createRequest = exports.encodeFilter = exports.decodeFilter = void 0;
|
|
4
4
|
function decodeFilter(filterString) {
|
|
5
5
|
try {
|
|
6
6
|
const filter = JSON.parse(decodeURIComponent(escape(atob(filterString))));
|
|
@@ -21,67 +21,16 @@ function encodeFilter(request) {
|
|
|
21
21
|
return btoa(unescape(encodeURIComponent(JSON.stringify(request))));
|
|
22
22
|
}
|
|
23
23
|
exports.encodeFilter = encodeFilter;
|
|
24
|
-
function createRequest(
|
|
24
|
+
function createRequest(request, defaultSort, defaultDir) {
|
|
25
25
|
var _a, _b;
|
|
26
26
|
return {
|
|
27
|
-
sort: (_a =
|
|
28
|
-
dir: (_b =
|
|
29
|
-
perPage:
|
|
30
|
-
page:
|
|
31
|
-
f:
|
|
32
|
-
search:
|
|
33
|
-
tab:
|
|
27
|
+
sort: (_a = request.sort) !== null && _a !== void 0 ? _a : defaultSort,
|
|
28
|
+
dir: (_b = request.dir) !== null && _b !== void 0 ? _b : defaultDir,
|
|
29
|
+
perPage: request.perPage,
|
|
30
|
+
page: request.page,
|
|
31
|
+
f: request.f.filter((f) => f.value !== undefined && f.value !== null && f.value !== ""),
|
|
32
|
+
search: request.search,
|
|
33
|
+
tab: request.tab,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
exports.createRequest = createRequest;
|
|
37
|
-
function toVal(mix) {
|
|
38
|
-
let k;
|
|
39
|
-
let y;
|
|
40
|
-
let str = "";
|
|
41
|
-
if (typeof mix === "string" || typeof mix === "number") {
|
|
42
|
-
str += mix;
|
|
43
|
-
}
|
|
44
|
-
else if (typeof mix === "object") {
|
|
45
|
-
if (Array.isArray(mix)) {
|
|
46
|
-
for (k = 0; k < mix.length; k++) {
|
|
47
|
-
if (mix[k]) {
|
|
48
|
-
if ((y = toVal(mix[k]))) {
|
|
49
|
-
if (str) {
|
|
50
|
-
str += " ";
|
|
51
|
-
}
|
|
52
|
-
str += y;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
for (k in mix) {
|
|
59
|
-
if (mix === null || mix === void 0 ? void 0 : mix[k]) {
|
|
60
|
-
if (str) {
|
|
61
|
-
str += " ";
|
|
62
|
-
}
|
|
63
|
-
str += k;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return str;
|
|
69
|
-
}
|
|
70
|
-
function cx(...classes) {
|
|
71
|
-
let i = 0;
|
|
72
|
-
let tmp;
|
|
73
|
-
let x;
|
|
74
|
-
let str = "";
|
|
75
|
-
while (i < classes.length) {
|
|
76
|
-
if ((tmp = classes[i++])) {
|
|
77
|
-
if ((x = toVal(tmp))) {
|
|
78
|
-
if (str) {
|
|
79
|
-
str += " ";
|
|
80
|
-
}
|
|
81
|
-
str += x;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return str;
|
|
86
|
-
}
|
|
87
|
-
exports.cx = cx;
|
package/hooks/useColumns.d.ts
DELETED