jb-grid 0.4.0 → 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/Components/module-declaration.d.ts +1 -1
- 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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GridTemplate } from "./types.js";
|
|
2
|
+
|
|
3
|
+
type CreateTemplateStylesheetOptions = {
|
|
4
|
+
selector: string,
|
|
5
|
+
autoModeVariableName?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createTemplateStylesheet(sheet: CSSStyleSheet, template: GridTemplate | null, options: CreateTemplateStylesheetOptions) {
|
|
9
|
+
const autoModeVariable = options.autoModeVariableName ? `${options.autoModeVariableName}: auto;` : "";
|
|
10
|
+
if (template === null) {
|
|
11
|
+
const css = /* css */ `
|
|
12
|
+
${options.selector}{
|
|
13
|
+
display:grid;
|
|
14
|
+
grid-auto-columns: 1fr;
|
|
15
|
+
grid-auto-flow: column;
|
|
16
|
+
grid-template-rows: 1fr;
|
|
17
|
+
${autoModeVariable}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
sheet.replaceSync(css);
|
|
21
|
+
return sheet;
|
|
22
|
+
}
|
|
23
|
+
let gridTemplateColumns = "";
|
|
24
|
+
const gridTemplateAreas = template.map(t => `${t.name}`).join(" ");
|
|
25
|
+
template.forEach((item) => {
|
|
26
|
+
if (item.size != null || item.size != undefined) {
|
|
27
|
+
if (typeof item.size == "number") {
|
|
28
|
+
gridTemplateColumns += ` ${item.size}px`;
|
|
29
|
+
} else {
|
|
30
|
+
gridTemplateColumns += ` ${item.size}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
} else {
|
|
34
|
+
gridTemplateColumns += " 1fr";
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const css = /* css */ `
|
|
38
|
+
${options.selector}{
|
|
39
|
+
display:grid;
|
|
40
|
+
grid-template-columns: ${gridTemplateColumns};
|
|
41
|
+
grid-template-areas: "${gridTemplateAreas}"
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
sheet.replaceSync(css);
|
|
45
|
+
return sheet;
|
|
46
|
+
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { fetchResponseHandler, fetchErrorHandler } from 'jb-modules/FetchHandler/dist/FetchHandler.cjs.min'
|
|
2
|
-
import RequestData from 'jb-modules/RequestModule/dist/RequestData.cjs.min'
|
|
3
|
-
class JBGridBridge {
|
|
4
|
-
//public
|
|
5
|
-
mapServerResponseDataToGridData(data) {
|
|
6
|
-
//convert server response data to grid standard data
|
|
7
|
-
if (!data.content.length > -1 || !data.size || !data.numberOfElements) {
|
|
8
|
-
console.error('we cant set meta data')
|
|
9
|
-
}
|
|
10
|
-
var bridgeData = {}
|
|
11
|
-
//the content array contain data we want to show
|
|
12
|
-
bridgeData.content = data.content;
|
|
13
|
-
//current list start index to show to user exp:20-35 its 20
|
|
14
|
-
bridgeData.startItemIndex = data.size * data.number + 1;
|
|
15
|
-
//last index of current loaded list
|
|
16
|
-
bridgeData.endItemIndex = data.size * data.number + data.numberOfElements;
|
|
17
|
-
//all item count for example if we had 500 user its 500
|
|
18
|
-
bridgeData.totalItemsCount = data.totalElements;
|
|
19
|
-
//how many page we have
|
|
20
|
-
bridgeData.totalPages = data.totalPages;
|
|
21
|
-
//current loaded page index
|
|
22
|
-
bridgeData.pageIndex = data.number + 1;//our server page start index from 0
|
|
23
|
-
return bridgeData;
|
|
24
|
-
}
|
|
25
|
-
//public
|
|
26
|
-
createRequestBody(pageObj, filterObj, sortColumn, dataConfig) {
|
|
27
|
-
//create body of request to send to the server
|
|
28
|
-
|
|
29
|
-
var requestBody = {}
|
|
30
|
-
//به خاطر اینکه صفحه بندی سرور از صفر شروع میشده
|
|
31
|
-
requestBody.page = pageObj.index - 1;
|
|
32
|
-
requestBody.size = pageObj.size;
|
|
33
|
-
/* implement grid filter */
|
|
34
|
-
if (filterObj) {
|
|
35
|
-
var bodyFilterObject = this._mapJBSearchBarFilterObjectToServerFilterObject(filterObj);
|
|
36
|
-
if (bodyFilterObject.length > 0) {
|
|
37
|
-
requestBody.criteria = bodyFilterObject
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
//implement user sort config to request body
|
|
41
|
-
this._implementSortToRequestBody(sortColumn, requestBody);
|
|
42
|
-
return requestBody;
|
|
43
|
-
}
|
|
44
|
-
getData(configData, requestBody) {
|
|
45
|
-
return new Promise((resolve, reject) => {
|
|
46
|
-
var request = new RequestData({
|
|
47
|
-
url: configData.url,
|
|
48
|
-
method: configData.method,
|
|
49
|
-
body: requestBody
|
|
50
|
-
});
|
|
51
|
-
fetch(request.request).then(fetchResponseHandler(request)).then((data) => {
|
|
52
|
-
resolve(data);
|
|
53
|
-
}).catch((err) => {
|
|
54
|
-
fetchErrorHandler(err);
|
|
55
|
-
reject(err);
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
//private . not need for jb grid bridge
|
|
60
|
-
_mapJBSearchBarFilterObjectToServerFilterObject(JBSearchBarFilterObject) {
|
|
61
|
-
var filterList = [];
|
|
62
|
-
JBSearchBarFilterObject.forEach((filter, index) => {
|
|
63
|
-
var value = filter.value.value;
|
|
64
|
-
var key = filter.column.name;
|
|
65
|
-
if (!filter.column.operation) {
|
|
66
|
-
filter.column.operation = "EQUALITY"
|
|
67
|
-
}
|
|
68
|
-
filterList.push({
|
|
69
|
-
"key": key,
|
|
70
|
-
"operation": filter.column.operation,
|
|
71
|
-
"value": value
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
return filterList;
|
|
75
|
-
}
|
|
76
|
-
//private
|
|
77
|
-
_implementSortToRequestBody(sortColumn, requestBody) {
|
|
78
|
-
if (sortColumn) {
|
|
79
|
-
if (!requestBody.criteria) {
|
|
80
|
-
requestBody.criteria = []
|
|
81
|
-
}
|
|
82
|
-
requestBody.criteria.push({
|
|
83
|
-
"key": sortColumn.name,
|
|
84
|
-
"operation": 'SORT_BY',
|
|
85
|
-
"value": sortColumn.sort.toUpperCase()
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
export default JBGridBridge;
|
package/react/lib/JBGridData.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { makeObservable, observable } from 'mobx';
|
|
2
|
-
import { JBGridConfigStates, JBGridDataPage, JBGridTableConfig,JBGridCallbackConfig, JBGridI18nConfig, JBGridDataConfig, JBGridConfigInterface, AnyObject } from './types.js';
|
|
3
|
-
|
|
4
|
-
class JBGridData<T extends AnyObject> implements JBGridConfigInterface<T> {
|
|
5
|
-
constructor(){
|
|
6
|
-
makeObservable(this,{
|
|
7
|
-
table:observable,
|
|
8
|
-
data:observable,
|
|
9
|
-
page:observable,
|
|
10
|
-
states:observable
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
table:JBGridTableConfig = {
|
|
14
|
-
columns: []
|
|
15
|
-
}
|
|
16
|
-
data:JBGridDataConfig<T> = {
|
|
17
|
-
data: [],
|
|
18
|
-
requestParams:{
|
|
19
|
-
method:"GET",
|
|
20
|
-
url:""
|
|
21
|
-
},
|
|
22
|
-
//keep detail of which items we show in a grid and detail of what information do we have
|
|
23
|
-
metaData: {
|
|
24
|
-
startItemIndex: 0,
|
|
25
|
-
endItemIndex: 0,
|
|
26
|
-
totalItemsCount: 0
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
page:JBGridDataPage = {
|
|
30
|
-
index: 1,
|
|
31
|
-
size: 20,
|
|
32
|
-
totalPages: 1,
|
|
33
|
-
}
|
|
34
|
-
states:JBGridConfigStates = {
|
|
35
|
-
headerSection: "MAIN",
|
|
36
|
-
isFullScreen: false
|
|
37
|
-
}
|
|
38
|
-
callbacks:JBGridCallbackConfig<any> = {
|
|
39
|
-
//TODO: define standard callback for grid like onRefresh , onDataLoad ,onFullScreen , onFilter ,....
|
|
40
|
-
onPageIndexChange: null, //when grid pageIndex change
|
|
41
|
-
onDataStandardizing: null //when we retrive new data and let outside programmer change the data structure before it compile
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated provide it as a prop
|
|
46
|
-
*/
|
|
47
|
-
customComponents = {
|
|
48
|
-
headerEnd: []
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export {JBGridData};
|
package/react/lib/global.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type FileStringModules = {
|
|
2
|
-
readonly default: string;
|
|
3
|
-
}
|
|
4
|
-
declare module '*.css' {
|
|
5
|
-
const value: FileStringModules;
|
|
6
|
-
export default value;
|
|
7
|
-
}
|
|
8
|
-
declare module '*.html' {
|
|
9
|
-
const value: FileStringModules;
|
|
10
|
-
export default value.default;
|
|
11
|
-
}
|
|
12
|
-
declare module '*.svg' {
|
|
13
|
-
const value: string;
|
|
14
|
-
export default value;
|
|
15
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type FileStringModules = {
|
|
2
|
-
readonly default: string;
|
|
3
|
-
}
|
|
4
|
-
declare module '*.css' {
|
|
5
|
-
const value: FileStringModules;
|
|
6
|
-
export default value;
|
|
7
|
-
}
|
|
8
|
-
declare module '*.html' {
|
|
9
|
-
const value: FileStringModules;
|
|
10
|
-
export default value.default;
|
|
11
|
-
}
|
|
12
|
-
declare module '*.svg' {
|
|
13
|
-
const value: string;
|
|
14
|
-
export default value;
|
|
15
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
"rootDir": "./lib",
|
|
5
|
-
"declarationDir": "./dist",
|
|
6
|
-
},
|
|
7
|
-
"include": [
|
|
8
|
-
"lib/global.d.ts",
|
|
9
|
-
"lib/**/*.ts",
|
|
10
|
-
],
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"**/*.spec.ts",
|
|
14
|
-
"dist",
|
|
15
|
-
],
|
|
16
|
-
"extends":"jb-core/configs/tsconfig-web-component.json"
|
|
17
|
-
}
|