jb-grid 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -11
- package/package.json +5 -8
- package/react/README.md +207 -202
- package/react/dist/Content.d.ts +1 -2
- package/react/dist/Footer.d.ts +1 -2
- package/react/dist/Header.d.ts +3 -16
- package/react/dist/JBGrid.cjs.js +3631 -1
- package/react/dist/JBGrid.cjs.js.map +1 -1
- package/react/dist/JBGrid.d.ts +288 -26
- package/react/dist/JBGrid.js +3624 -1
- package/react/dist/JBGrid.js.map +1 -1
- package/react/dist/JBGrid.umd.js +3641 -1
- package/react/dist/JBGrid.umd.js.map +1 -1
- package/react/dist/JBGridData.d.ts +1 -5
- package/react/dist/JBGridViewModel.d.ts +28 -25
- package/react/dist/types.d.ts +17 -49
- package/react/lib/Components/Cell.tsx +17 -15
- package/react/lib/Components/ColumnHeader.tsx +44 -0
- package/react/lib/Components/ExpandToggle.tsx +14 -10
- package/react/lib/Components/FullscreenIcon.tsx +28 -0
- package/react/lib/Components/JBLoading.tsx +5 -4
- package/react/lib/Components/Pagination.tsx +1 -1
- package/react/lib/Components/PaginationInfo.tsx +71 -0
- package/react/lib/Components/RefreshIcon.tsx +11 -0
- package/react/lib/Components/Row.tsx +17 -15
- package/react/lib/Components/TableHeader.tsx +21 -0
- package/react/lib/Components/blob-loading.css +27 -23
- package/react/lib/Components/cell.css +7 -7
- package/react/lib/Components/content-error/ContentError.tsx +19 -16
- package/react/lib/Components/content-error/content-error.css +5 -11
- package/react/lib/Components/module-declaration.ts +61 -13
- package/react/lib/Content.tsx +23 -47
- package/react/lib/Footer.tsx +52 -79
- package/react/lib/Header.tsx +11 -24
- package/react/lib/JBGrid.tsx +129 -70
- package/react/lib/JBGridViewModel.ts +189 -452
- package/react/lib/footer.css +25 -55
- package/react/lib/header.css +20 -20
- package/react/lib/jb-grid.css +69 -55
- package/react/lib/types.ts +32 -129
- package/react/lib/variables.css +6 -0
- package/react/package.json +14 -10
- package/react/tsconfig.json +5 -4
- package/web-component/dist/index.cjs.js +559 -1
- package/web-component/dist/index.cjs.js.br +0 -0
- package/web-component/dist/index.cjs.js.gz +0 -0
- package/web-component/dist/index.cjs.js.map +1 -1
- package/web-component/dist/index.d.ts +161 -4
- package/web-component/dist/index.d.ts.map +1 -1
- package/web-component/dist/index.js +561 -1
- package/web-component/dist/index.js.br +0 -0
- package/web-component/dist/index.js.gz +0 -0
- package/web-component/dist/index.js.map +1 -1
- package/web-component/dist/index.umd.js +567 -1
- package/web-component/dist/index.umd.js.br +0 -0
- package/web-component/dist/index.umd.js.gz +0 -0
- package/web-component/dist/index.umd.js.map +1 -1
- package/web-component/dist/row/row.d.ts.map +1 -1
- package/web-component/dist/row/types.d.ts +3 -5
- package/web-component/dist/row/types.d.ts.map +1 -1
- package/web-component/dist/row/utils.d.ts +1 -2
- package/web-component/dist/row/utils.d.ts.map +1 -1
- package/web-component/dist/table-header/render.d.ts +2 -0
- package/web-component/dist/table-header/render.d.ts.map +1 -0
- package/web-component/dist/table-header/table-header.d.ts +9 -0
- package/web-component/dist/table-header/table-header.d.ts.map +1 -0
- package/web-component/dist/table-header/types.d.ts +4 -0
- package/web-component/dist/table-header/types.d.ts.map +1 -0
- package/web-component/dist/types.d.ts +6 -0
- package/web-component/dist/types.d.ts.map +1 -0
- package/web-component/dist/utils.d.ts +8 -0
- package/web-component/dist/utils.d.ts.map +1 -0
- package/web-component/lib/cell/cell.ts +10 -5
- package/web-component/lib/cell/style.css +2 -1
- package/web-component/lib/column-header/column-header.ts +117 -0
- package/web-component/lib/column-header/render.ts +14 -0
- package/web-component/lib/column-header/style.css +60 -0
- package/web-component/lib/column-header/types.ts +10 -0
- package/web-component/lib/fullscreen-icon/fullscreen-icon.ts +72 -0
- package/web-component/lib/fullscreen-icon/render.ts +23 -0
- package/web-component/lib/fullscreen-icon/style.css +44 -0
- package/web-component/lib/fullscreen-icon/types.ts +1 -0
- package/web-component/lib/i18n.ts +38 -0
- package/web-component/lib/index.ts +9 -4
- package/web-component/lib/pagination/README.md +4 -0
- package/web-component/lib/pagination/pagination.ts +25 -15
- package/web-component/lib/pagination/render.ts +13 -10
- package/web-component/lib/pagination/style.css +43 -31
- package/web-component/lib/pagination/types.ts +1 -1
- package/web-component/lib/pagination/variables.css +10 -0
- package/web-component/lib/pagination-info/pagination-info.ts +191 -0
- package/web-component/lib/pagination-info/render.ts +16 -0
- package/web-component/lib/pagination-info/style.css +47 -0
- package/web-component/lib/pagination-info/types.ts +12 -0
- package/web-component/lib/refresh-icon/refresh-icon.ts +79 -0
- package/web-component/lib/refresh-icon/render.ts +10 -0
- package/web-component/lib/refresh-icon/style.css +21 -0
- package/web-component/lib/row/render.ts +3 -3
- package/web-component/lib/row/row.ts +29 -15
- package/web-component/lib/row/style.css +30 -30
- package/web-component/lib/row/types.ts +7 -8
- package/web-component/lib/row/utils.ts +1 -40
- package/web-component/lib/row/variables.css +13 -0
- package/web-component/lib/table-header/render.ts +9 -0
- package/web-component/lib/table-header/style.css +29 -0
- package/web-component/lib/table-header/table-header.ts +50 -0
- package/web-component/lib/table-header/types.ts +4 -0
- package/web-component/lib/toggle/expand-toggle.ts +17 -13
- package/web-component/lib/toggle/render.ts +18 -13
- package/web-component/lib/toggle/style.css +18 -5
- package/web-component/lib/types.ts +6 -0
- package/web-component/lib/utils.ts +46 -0
- package/react/lib/JBGridBridgeExample.js +0 -90
- package/react/lib/JBGridData.ts +0 -51
- package/react/lib/global.d.ts +0 -15
- package/web-component/lib/global.d.ts +0 -15
- package/web-component/tsconfig.json +0 -17
package/react/lib/JBGrid.tsx
CHANGED
|
@@ -1,70 +1,129 @@
|
|
|
1
|
-
import React, { type ReactNode, useEffect } from 'react';
|
|
2
|
-
import JBGridViewModel, { JBGridContext } from './JBGridViewModel.js';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import BlobCSS from './Components/blob-loading.css';
|
|
6
|
-
|
|
7
|
-
import '
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
export * from './Components/
|
|
17
|
-
export * from './Components/
|
|
18
|
-
export * from './Components/
|
|
19
|
-
export * from './Components/
|
|
20
|
-
export * from './
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
import React, { type ReactNode, useEffect, useReducer } from 'react';
|
|
2
|
+
import JBGridViewModel, { JBGridContext } from './JBGridViewModel.js';
|
|
3
|
+
import CSS from './jb-grid.css?inline';
|
|
4
|
+
import VariablesCSS from './variables.css?inline';
|
|
5
|
+
import BlobCSS from './Components/blob-loading.css?inline';
|
|
6
|
+
import type { AnyObject, JBGridCallbacks, JBGridI18nConfig, JBGridRenderContext, JBGridRowData } from './types.js';
|
|
7
|
+
import Footer from './Footer.js';
|
|
8
|
+
import Header from './Header.js';
|
|
9
|
+
import Content from './Content.js';
|
|
10
|
+
import { useInstance } from 'jb-core/react';
|
|
11
|
+
import { injectCss } from 'jb-core';
|
|
12
|
+
|
|
13
|
+
export {JBPagination, type Props as PaginationProps} from './Components/Pagination.js';
|
|
14
|
+
export * from './Components/PaginationInfo.js';
|
|
15
|
+
export * from './Components/RefreshIcon.js';
|
|
16
|
+
export * from './Components/FullscreenIcon.js';
|
|
17
|
+
export * from './Components/Row.js';
|
|
18
|
+
export * from './Components/TableHeader.js';
|
|
19
|
+
export * from './Components/ColumnHeader.js';
|
|
20
|
+
export * from './Components/Cell.js';
|
|
21
|
+
export * from './Components/ExpandRow.js';
|
|
22
|
+
export * from './Components/ExpandToggle.js';
|
|
23
|
+
export * from './types.js';
|
|
24
|
+
export type Props<T extends AnyObject> = {
|
|
25
|
+
searchbarComponent?: ReactNode,
|
|
26
|
+
tableHeader?: ReactNode,
|
|
27
|
+
data: JBGridRowData<T>[],
|
|
28
|
+
pageIndex: number,
|
|
29
|
+
pageSize: number,
|
|
30
|
+
totalItemsCount: number,
|
|
31
|
+
totalPages?: number,
|
|
32
|
+
startItemIndex?: number,
|
|
33
|
+
endItemIndex?: number,
|
|
34
|
+
isLoading?: boolean,
|
|
35
|
+
isErrorOccurred?: boolean,
|
|
36
|
+
isFullscreen?: boolean,
|
|
37
|
+
className?: string,
|
|
38
|
+
style?: React.CSSProperties,
|
|
39
|
+
onFullscreen?: JBGridCallbacks["onFullscreen"],
|
|
40
|
+
onPageIndexChange?: JBGridCallbacks["onPageIndexChange"],
|
|
41
|
+
onPageSizeChange?: JBGridCallbacks["onPageSizeChange"],
|
|
42
|
+
onRefresh?: JBGridCallbacks["onRefresh"],
|
|
43
|
+
onExitFullscreen?: JBGridCallbacks["onExitFullscreen"],
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated use onFullscreen and onExitFullscreen instead
|
|
46
|
+
*/
|
|
47
|
+
onFullscreenChange?: JBGridCallbacks["onFullscreenChange"],
|
|
48
|
+
title: string,
|
|
49
|
+
i18n?: JBGridI18nConfig | null | undefined,
|
|
50
|
+
contentError?: ReactNode,
|
|
51
|
+
headerEndComponents?: ReactNode[] | ReactNode,
|
|
52
|
+
children?: React.ReactNode | React.ReactNode[] | ((data: JBGridRowData<T>[], context: JBGridRenderContext) => React.ReactNode | React.ReactNode[])
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
injectCss(VariablesCSS as unknown as string);
|
|
56
|
+
injectCss(CSS as unknown as string);
|
|
57
|
+
injectCss(BlobCSS as unknown as string);
|
|
58
|
+
|
|
59
|
+
function JBGridComponent<T extends AnyObject>(props: Props<T>) {
|
|
60
|
+
const [, forceUpdate] = useReducer((version: number) => version + 1, 0);
|
|
61
|
+
const vm = useInstance(JBGridViewModel, [{
|
|
62
|
+
onFullscreen: props.onFullscreen,
|
|
63
|
+
onPageIndexChange: props.onPageIndexChange,
|
|
64
|
+
onPageSizeChange: props.onPageSizeChange,
|
|
65
|
+
onRefresh: props.onRefresh,
|
|
66
|
+
onExitFullscreen: props.onExitFullscreen,
|
|
67
|
+
onFullscreenChange: props.onFullscreenChange
|
|
68
|
+
}, forceUpdate]);
|
|
69
|
+
|
|
70
|
+
const totalPages = props.totalPages ?? Math.max(1, Math.ceil(props.totalItemsCount / props.pageSize));
|
|
71
|
+
const startItemIndex = props.startItemIndex ?? ((props.pageIndex - 1) * props.pageSize) + (props.data.length > 0 ? 1 : 0);
|
|
72
|
+
const endItemIndex = props.endItemIndex ?? ((props.pageIndex - 1) * props.pageSize) + props.data.length;
|
|
73
|
+
|
|
74
|
+
vm.setGridState({
|
|
75
|
+
pageIndex: props.pageIndex,
|
|
76
|
+
pageSize: props.pageSize,
|
|
77
|
+
totalPages,
|
|
78
|
+
metaData: {
|
|
79
|
+
startItemIndex,
|
|
80
|
+
endItemIndex,
|
|
81
|
+
totalItemsCount: props.totalItemsCount
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
vm.setCallbacks({
|
|
87
|
+
onFullscreen: props.onFullscreen,
|
|
88
|
+
onPageIndexChange: props.onPageIndexChange,
|
|
89
|
+
onPageSizeChange: props.onPageSizeChange,
|
|
90
|
+
onRefresh: props.onRefresh,
|
|
91
|
+
onExitFullscreen: props.onExitFullscreen,
|
|
92
|
+
onFullscreenChange: props.onFullscreenChange
|
|
93
|
+
});
|
|
94
|
+
}, [vm, props.onFullscreen, props.onPageIndexChange, props.onPageSizeChange, props.onRefresh, props.onExitFullscreen, props.onFullscreenChange]);
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
vm.setStateChangeCallback(forceUpdate);
|
|
98
|
+
return () => {
|
|
99
|
+
vm.setStateChangeCallback(undefined);
|
|
100
|
+
};
|
|
101
|
+
}, [vm, forceUpdate]);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if(props.i18n){
|
|
105
|
+
vm.setI18n(props.i18n);
|
|
106
|
+
}
|
|
107
|
+
}, [props.i18n]);
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (props.isFullscreen !== null && props.isFullscreen !== undefined) {
|
|
111
|
+
vm.onFullscreenChanged(props.isFullscreen);
|
|
112
|
+
}
|
|
113
|
+
}, [props.isFullscreen]);
|
|
114
|
+
const renderContext: JBGridRenderContext = {
|
|
115
|
+
refreshView: () => vm.notifyStateChange()
|
|
116
|
+
};
|
|
117
|
+
const contentChildren = typeof props.children === "function" ? props.children(props.data, renderContext) : props.children;
|
|
118
|
+
return (
|
|
119
|
+
<JBGridContext.Provider value={vm} key={"jb-grid-context"}>
|
|
120
|
+
<div className={`jb-grid-wrapper ${props.className ?? ""}`} ref={vm.JBGridComponentDom} style={props.style}>
|
|
121
|
+
<Header title={props.title} vm={vm} searchbarComponent={props.searchbarComponent} headerEndComponents={props.headerEndComponents}></Header>
|
|
122
|
+
<Content i18n={vm.i18n} tableHeader={props.tableHeader} isErrorOccurred={props.isErrorOccurred ?? false} isLoading={props.isLoading ?? false} refreshBtnClick={vm.refreshBtnClick} errorComponent={props.contentError}>{contentChildren}</Content>
|
|
123
|
+
<Footer isFullscreen={props.isFullscreen ?? false} vm={vm}></Footer>
|
|
124
|
+
</div>
|
|
125
|
+
</JBGridContext.Provider>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export const JBGrid = JBGridComponent;
|