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.
Files changed (117) hide show
  1. package/README.md +138 -11
  2. package/package.json +5 -8
  3. package/react/README.md +207 -202
  4. package/react/dist/Content.d.ts +1 -2
  5. package/react/dist/Footer.d.ts +1 -2
  6. package/react/dist/Header.d.ts +3 -16
  7. package/react/dist/JBGrid.cjs.js +3631 -1
  8. package/react/dist/JBGrid.cjs.js.map +1 -1
  9. package/react/dist/JBGrid.d.ts +288 -26
  10. package/react/dist/JBGrid.js +3624 -1
  11. package/react/dist/JBGrid.js.map +1 -1
  12. package/react/dist/JBGrid.umd.js +3641 -1
  13. package/react/dist/JBGrid.umd.js.map +1 -1
  14. package/react/dist/JBGridData.d.ts +1 -5
  15. package/react/dist/JBGridViewModel.d.ts +28 -25
  16. package/react/dist/types.d.ts +17 -49
  17. package/react/lib/Components/Cell.tsx +17 -15
  18. package/react/lib/Components/ColumnHeader.tsx +44 -0
  19. package/react/lib/Components/ExpandToggle.tsx +14 -10
  20. package/react/lib/Components/FullscreenIcon.tsx +28 -0
  21. package/react/lib/Components/JBLoading.tsx +5 -4
  22. package/react/lib/Components/Pagination.tsx +1 -1
  23. package/react/lib/Components/PaginationInfo.tsx +71 -0
  24. package/react/lib/Components/RefreshIcon.tsx +11 -0
  25. package/react/lib/Components/Row.tsx +17 -15
  26. package/react/lib/Components/TableHeader.tsx +21 -0
  27. package/react/lib/Components/blob-loading.css +27 -23
  28. package/react/lib/Components/cell.css +7 -7
  29. package/react/lib/Components/content-error/ContentError.tsx +19 -16
  30. package/react/lib/Components/content-error/content-error.css +5 -11
  31. package/react/lib/Components/module-declaration.ts +61 -13
  32. package/react/lib/Content.tsx +23 -47
  33. package/react/lib/Footer.tsx +52 -79
  34. package/react/lib/Header.tsx +11 -24
  35. package/react/lib/JBGrid.tsx +129 -70
  36. package/react/lib/JBGridViewModel.ts +189 -452
  37. package/react/lib/footer.css +25 -55
  38. package/react/lib/header.css +20 -20
  39. package/react/lib/jb-grid.css +69 -55
  40. package/react/lib/types.ts +32 -129
  41. package/react/lib/variables.css +6 -0
  42. package/react/package.json +14 -10
  43. package/react/tsconfig.json +5 -4
  44. package/web-component/dist/index.cjs.js +559 -1
  45. package/web-component/dist/index.cjs.js.br +0 -0
  46. package/web-component/dist/index.cjs.js.gz +0 -0
  47. package/web-component/dist/index.cjs.js.map +1 -1
  48. package/web-component/dist/index.d.ts +161 -4
  49. package/web-component/dist/index.d.ts.map +1 -1
  50. package/web-component/dist/index.js +561 -1
  51. package/web-component/dist/index.js.br +0 -0
  52. package/web-component/dist/index.js.gz +0 -0
  53. package/web-component/dist/index.js.map +1 -1
  54. package/web-component/dist/index.umd.js +567 -1
  55. package/web-component/dist/index.umd.js.br +0 -0
  56. package/web-component/dist/index.umd.js.gz +0 -0
  57. package/web-component/dist/index.umd.js.map +1 -1
  58. package/web-component/dist/row/row.d.ts.map +1 -1
  59. package/web-component/dist/row/types.d.ts +3 -5
  60. package/web-component/dist/row/types.d.ts.map +1 -1
  61. package/web-component/dist/row/utils.d.ts +1 -2
  62. package/web-component/dist/row/utils.d.ts.map +1 -1
  63. package/web-component/dist/table-header/render.d.ts +2 -0
  64. package/web-component/dist/table-header/render.d.ts.map +1 -0
  65. package/web-component/dist/table-header/table-header.d.ts +9 -0
  66. package/web-component/dist/table-header/table-header.d.ts.map +1 -0
  67. package/web-component/dist/table-header/types.d.ts +4 -0
  68. package/web-component/dist/table-header/types.d.ts.map +1 -0
  69. package/web-component/dist/types.d.ts +6 -0
  70. package/web-component/dist/types.d.ts.map +1 -0
  71. package/web-component/dist/utils.d.ts +8 -0
  72. package/web-component/dist/utils.d.ts.map +1 -0
  73. package/web-component/lib/cell/cell.ts +10 -5
  74. package/web-component/lib/cell/style.css +2 -1
  75. package/web-component/lib/column-header/column-header.ts +117 -0
  76. package/web-component/lib/column-header/render.ts +14 -0
  77. package/web-component/lib/column-header/style.css +60 -0
  78. package/web-component/lib/column-header/types.ts +10 -0
  79. package/web-component/lib/fullscreen-icon/fullscreen-icon.ts +72 -0
  80. package/web-component/lib/fullscreen-icon/render.ts +23 -0
  81. package/web-component/lib/fullscreen-icon/style.css +44 -0
  82. package/web-component/lib/fullscreen-icon/types.ts +1 -0
  83. package/web-component/lib/i18n.ts +38 -0
  84. package/web-component/lib/index.ts +9 -4
  85. package/web-component/lib/pagination/README.md +4 -0
  86. package/web-component/lib/pagination/pagination.ts +25 -15
  87. package/web-component/lib/pagination/render.ts +13 -10
  88. package/web-component/lib/pagination/style.css +43 -31
  89. package/web-component/lib/pagination/types.ts +1 -1
  90. package/web-component/lib/pagination/variables.css +10 -0
  91. package/web-component/lib/pagination-info/pagination-info.ts +191 -0
  92. package/web-component/lib/pagination-info/render.ts +16 -0
  93. package/web-component/lib/pagination-info/style.css +47 -0
  94. package/web-component/lib/pagination-info/types.ts +12 -0
  95. package/web-component/lib/refresh-icon/refresh-icon.ts +79 -0
  96. package/web-component/lib/refresh-icon/render.ts +10 -0
  97. package/web-component/lib/refresh-icon/style.css +21 -0
  98. package/web-component/lib/row/render.ts +3 -3
  99. package/web-component/lib/row/row.ts +29 -15
  100. package/web-component/lib/row/style.css +30 -30
  101. package/web-component/lib/row/types.ts +7 -8
  102. package/web-component/lib/row/utils.ts +1 -40
  103. package/web-component/lib/row/variables.css +13 -0
  104. package/web-component/lib/table-header/render.ts +9 -0
  105. package/web-component/lib/table-header/style.css +29 -0
  106. package/web-component/lib/table-header/table-header.ts +50 -0
  107. package/web-component/lib/table-header/types.ts +4 -0
  108. package/web-component/lib/toggle/expand-toggle.ts +17 -13
  109. package/web-component/lib/toggle/render.ts +18 -13
  110. package/web-component/lib/toggle/style.css +18 -5
  111. package/web-component/lib/types.ts +6 -0
  112. package/web-component/lib/utils.ts +46 -0
  113. package/react/lib/JBGridBridgeExample.js +0 -90
  114. package/react/lib/JBGridData.ts +0 -51
  115. package/react/lib/global.d.ts +0 -15
  116. package/web-component/lib/global.d.ts +0 -15
  117. package/web-component/tsconfig.json +0 -17
@@ -1,23 +1,26 @@
1
- import React from 'react';
2
- import CSS from './content-error.css';
3
- import { injectCss } from 'jb-core';
1
+ import React from 'react';
2
+ import CSS from './content-error.css?inline';
3
+ import { injectCss } from 'jb-core';
4
+ import { JBButton } from 'jb-button/react';
4
5
 
5
6
  injectCss(CSS as unknown as string);
6
7
  type ContentErrorProps = {
7
- onRefreshBtnClick:()=>unknown,
8
- message?:string,
9
- title?:string,
10
- refreshButtonTitle?:string,
8
+ onRefreshBtnClick: () => unknown,
9
+ message?: string,
10
+ title?: string,
11
+ refreshButtonTitle?: string,
11
12
  }
12
- function ContentError(props:ContentErrorProps) {
13
+ function ContentError(props: ContentErrorProps) {
13
14
  return (
14
15
  <div className="content-error">
15
- <div className="error-image">😬😓🤔</div>
16
- <div className="error-text" style={{ padding: " 0 0 0 0" }}>{props.title}</div>
17
- <div className="error-text">{props.message}</div>
18
- <div className="error-button"><button onClick={props.onRefreshBtnClick}>{props.refreshButtonTitle}</button></div>
19
- </div>
20
- );
21
- }
16
+ <div className="error-image">😬😓🤔</div>
17
+ <div className="error-text" style={{ padding: " 0 0 0 0" }}>{props.title}</div>
18
+ <div className="error-text">{props.message}</div>
19
+ <div className="error-button">
20
+ <JBButton color="positive" onClick={props.onRefreshBtnClick}>{props.refreshButtonTitle}</JBButton>
21
+ </div>
22
+ </div>
23
+ );
24
+ }
22
25
 
23
- export default ContentError;
26
+ export default ContentError;
@@ -11,16 +11,10 @@
11
11
  .error-text {
12
12
  font-weight: 100;
13
13
  font-size: 1.5em;
14
- padding: 16px 0;
14
+ padding: 1rem 0;
15
15
  color: #333;
16
16
  }
17
- .error-button button {
18
- padding: 8px 16px;
19
- background: green;
20
- color: #fff;
21
- border: none;
22
- border-radius: 150px;
23
- cursor: pointer;
24
- font-family: inherit;
25
- }
26
- }
17
+ .error-button {
18
+ margin-top: 0.5rem;
19
+ }
20
+ }
@@ -1,22 +1,70 @@
1
- import type { DetailedHTMLProps, HTMLAttributes } from "react";
2
- import type { JBPaginationWebComponent } from "jb-grid";
3
- import type { JBPaginationDirectAttributeProps } from "./types";
4
- import type {JBCellWebComponent, JBRowWebComponent, JBExpandToggleWebComponent} from 'jb-grid'
5
- type JBPaginationAttributes = DetailedHTMLProps<HTMLAttributes<JBPaginationWebComponent>, JBPaginationWebComponent> & JBPaginationDirectAttributeProps
6
- export type JBRowAttributes = DetailedHTMLProps<HTMLAttributes<JBRowWebComponent>, JBRowWebComponent>
7
- export type JBCellAttributes = DetailedHTMLProps<HTMLAttributes<JBCellWebComponent>, JBCellWebComponent> & {
8
- ellipsis?: boolean | number
9
- }
1
+ import type { DetailedHTMLProps, HTMLAttributes } from "react";
2
+ import type { JBPaginationWebComponent } from "jb-grid";
3
+ import type { JBPaginationDirectAttributeProps } from "./types";
4
+ import type {JBCellWebComponent, JBRowWebComponent, JBExpandToggleWebComponent} from 'jb-grid'
5
+ type TableHeaderTemplate = Array<{name: string, size?: string | number}>
6
+ type JBTableHeaderWebComponent = HTMLElement & {
7
+ headerTemplate: TableHeaderTemplate
8
+ }
9
+ type JBColumnHeaderSort = "asc" | "desc";
10
+ type JBColumnHeaderWebComponent = HTMLElement & {
11
+ name: string,
12
+ sortable: boolean,
13
+ sort: JBColumnHeaderSort | null
14
+ }
15
+ type JBPaginationInfoWebComponent = HTMLElement & {
16
+ pageSize: number,
17
+ pageSizes: number[],
18
+ startItemIndex: number,
19
+ endItemIndex: number,
20
+ totalItemsCount: number,
21
+ pageItemCountTitle: string,
22
+ fromLabel: string,
23
+ currentAvailableItemTitle: string,
24
+ showPersianNumber: boolean
25
+ }
26
+ export type JBRefreshIconWebComponent = HTMLElement & {
27
+ play: () => void,
28
+ pause: () => void,
29
+ stop: () => void
30
+ }
31
+ type JBFullscreenIconState = "enter" | "exit";
32
+ type JBFullscreenIconWebComponent = HTMLElement & {
33
+ state: JBFullscreenIconState
34
+ }
35
+ type JBPaginationAttributes = DetailedHTMLProps<HTMLAttributes<JBPaginationWebComponent>, JBPaginationWebComponent> & JBPaginationDirectAttributeProps
36
+ export type JBPaginationInfoAttributes = DetailedHTMLProps<HTMLAttributes<JBPaginationInfoWebComponent>, JBPaginationInfoWebComponent>
37
+ export type JBRefreshIconAttributes = DetailedHTMLProps<HTMLAttributes<JBRefreshIconWebComponent>, JBRefreshIconWebComponent>
38
+ export type JBFullscreenIconAttributes = DetailedHTMLProps<HTMLAttributes<JBFullscreenIconWebComponent>, JBFullscreenIconWebComponent> & {
39
+ state?: JBFullscreenIconState
40
+ }
41
+ export type JBRowAttributes = DetailedHTMLProps<HTMLAttributes<JBRowWebComponent>, JBRowWebComponent>
42
+ export type JBTableHeaderAttributes = DetailedHTMLProps<HTMLAttributes<JBTableHeaderWebComponent>, JBTableHeaderWebComponent> & {
43
+ headerTemplate?: TableHeaderTemplate
44
+ }
45
+ export type JBColumnHeaderAttributes = DetailedHTMLProps<HTMLAttributes<JBColumnHeaderWebComponent>, JBColumnHeaderWebComponent> & {
46
+ name: string,
47
+ sortable?: boolean,
48
+ sort?: JBColumnHeaderSort
49
+ }
50
+ export type JBCellAttributes = DetailedHTMLProps<HTMLAttributes<JBCellWebComponent>, JBCellWebComponent> & {
51
+ ellipsis?: boolean | number
52
+ }
10
53
  export type JBExpandToggleAttributes = DetailedHTMLProps<HTMLAttributes<JBExpandToggleWebComponent>, JBExpandToggleWebComponent>
11
54
 
12
55
  declare module "react" {
13
56
  // eslint-disable-next-line @typescript-eslint/no-namespace
14
57
  namespace JSX {
15
58
  interface IntrinsicElements {
16
- 'jb-pagination': JBPaginationAttributes;
17
- 'jb-row': JBRowAttributes;
18
- 'jb-cell': JBCellAttributes;
19
- 'jb-expand-toggle': JBExpandToggleAttributes;
59
+ 'jb-pagination': JBPaginationAttributes;
60
+ 'jb-pagination-info': JBPaginationInfoAttributes;
61
+ 'jb-refresh-icon': JBRefreshIconAttributes;
62
+ 'jb-fullscreen-icon': JBFullscreenIconAttributes;
63
+ 'jb-row': JBRowAttributes;
64
+ 'jb-table-header': JBTableHeaderAttributes;
65
+ 'jb-col-header': JBColumnHeaderAttributes;
66
+ 'jb-cell': JBCellAttributes;
67
+ 'jb-expand-toggle': JBExpandToggleAttributes;
20
68
  }
21
69
  }
22
70
  }
@@ -1,55 +1,31 @@
1
- import { observer } from 'mobx-react';
2
- import React, { ReactNode } from 'react';
3
- import JBLoading from './Components/JBLoading.js';
4
- import { JBGridColumnDef, JBGridConfig, JBGridI18nConfig, JBGridStyles } from './types.js';
5
- import ContentError from './Components/content-error/ContentError.js';
6
- export type ContentProps = {
7
- children:React.ReactNode | React.ReactNode[],
8
- refreshBtnClick:()=>void,
9
- config:JBGridConfig<any>,
10
- isErrorOccurred:boolean,
11
- styles:JBGridStyles,
12
- isLoading:boolean,
13
- setSortColumn:(column: JBGridColumnDef) => void,
14
- i18n:JBGridI18nConfig,
15
- errorComponent?:ReactNode,
16
- }
17
- function Content(props:ContentProps) {
18
- const {refreshBtnClick,config,isErrorOccurred,styles,isLoading,setSortColumn,i18n} = props;
19
- const ErrorComponent = props.errorComponent || <ContentError onRefreshBtnClick={refreshBtnClick} message={i18n.messages?.serverErrorText} title={i18n.messages?.serverErrorTitle} refreshButtonTitle={i18n.messages!.serverErrorRefreshButtonTitle}></ContentError>;
20
-
21
- return (
22
- <section key={'jb-grid-content'} className="jb-grid-content">
1
+ import React, { type ReactNode } from 'react';
2
+ import JBLoading from './Components/JBLoading.js';
3
+ import type { JBGridI18nConfig } from './types.js';
4
+ import ContentError from './Components/content-error/ContentError.js';
5
+ export type ContentProps = {
6
+ children:React.ReactNode | React.ReactNode[],
7
+ refreshBtnClick:()=>void,
8
+ isErrorOccurred:boolean,
9
+ isLoading:boolean,
10
+ i18n:JBGridI18nConfig,
11
+ errorComponent?:ReactNode,
12
+ tableHeader?:ReactNode,
13
+ }
14
+ function Content(props:ContentProps) {
15
+ const {refreshBtnClick,isErrorOccurred,isLoading,i18n} = props;
16
+ const ErrorComponent = props.errorComponent || <ContentError onRefreshBtnClick={refreshBtnClick} message={i18n.messages?.serverErrorText} title={i18n.messages?.serverErrorTitle} refreshButtonTitle={i18n.messages!.serverErrorRefreshButtonTitle}></ContentError>;
17
+
18
+ return (
19
+ <section key={'jb-grid-content'} className={`jb-grid-content ${props.tableHeader ? "" : "without-table-header"}`}>
23
20
  {
24
21
  isErrorOccurred &&
25
22
  ErrorComponent
26
23
  }
27
24
  {
28
25
  !isErrorOccurred &&
29
- [
30
- <section className="table-header" key='table-header'>
31
- <div className="table-header-wrapper" style={{ ...styles.table.generalCols, ...styles.table.scrollIndent }}>
32
- {
33
- config.table.columns.map((item) => {
34
- return (
35
- <div onClick={() => setSortColumn(item)} key={item.name + '-' + item.id + '-' + "jb-grid-table-header"} title={item.name} className={'header-item ' + (item.sortable ? 'sortable-col' : '')}>
36
- <div className="caption-wrapper">{item.title}</div>
37
- {
38
- item.sort && (
39
- <div className={"sort-icon-wrapper"}>
40
- <svg className={'--' + item.sort.toLowerCase()} version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 31.479 31.479">
41
- <path d="M26.477,10.274c0.444,0.444,0.444,1.143,0,1.587c-0.429,0.429-1.143,0.429-1.571,0l-8.047-8.047 v26.555c0,0.619-0.492,1.111-1.111,1.111c-0.619,0-1.127-0.492-1.127-1.111V3.813l-8.031,8.047c-0.444,0.429-1.159,0.429-1.587,0 c-0.444-0.444-0.444-1.143,0-1.587l9.952-9.952c0.429-0.429,1.143-0.429,1.571,0L26.477,10.274z" />
42
- </svg>
43
-
44
- </div>
45
- )}
46
- </div>
47
- );
48
- })
49
- }
50
- </div>
51
- </section>
52
- ,
26
+ [
27
+ props.tableHeader && <section className="table-header" key='table-header'>{props.tableHeader}</section>
28
+ ,
53
29
  <section className="table-content" key='table-content'>
54
30
  <div className="table-content-wrapper">
55
31
  {props.children}
@@ -73,4 +49,4 @@ function Content(props:ContentProps) {
73
49
  );
74
50
  }
75
51
 
76
- export default observer(Content);
52
+ export default Content;
@@ -1,79 +1,52 @@
1
- import { observer } from 'mobx-react';
2
- import React, { type Ref } from 'react';
3
- import type JBGridViewModel from './JBGridViewModel.js';
4
- import CSS from './footer.css';
5
- import { injectCss } from 'jb-core';
6
- import { JBPagination } from './JBGrid.js';
7
- import type { JBPaginationWebComponent } from 'jb-grid';
8
- injectCss(CSS as unknown as string);
9
- type FooterProps = {
10
- vm:JBGridViewModel<any>,
11
- isFullscreen:boolean
12
- }
13
- function Footer(props:FooterProps) {
14
- const {vm,isFullscreen} = props;
15
- return (
16
- <section key={'jb-grid-footer'} className="jb-grid-footer">
17
- <section className="btn-wrapper-section">
18
- {
19
- isFullscreen !== null && isFullscreen !== undefined && (
20
- <div className="btn full-screen-button" onClick={() => vm.onFullScreenBtnClicked(isFullscreen)}>
21
- <svg xmlns="http://www.w3.org/2000/svg" version="1.0" x="0px" y="0px" viewBox="0 0 128 128" className={isFullscreen ? 'exit-full-screen-svg' : 'full-screen-svg'}>
22
- <title>Full Screen Button</title>
23
- <g className="arrow" transform={!isFullscreen ? '' : "translate(0, 0) rotate(180 30 30)"}>
24
- <path d="M47.979,41.795L26.466,20.292c-3.995-6.034,6.546-6.069,6.546-6.069h6.385c4.054-0.105,6.282-2.363,6.24-5.229 c-0.041-2.866-1.591-5.216-5.167-5.151H23.679C-0.4,2.575,0.342,20.363,0.755,24.486c0.02,0.208-0.015,0.375,0,0.502v0.025 l0.011,15.21c-0.029,2.556,1.211,5.834,4.501,6.265c3.329,0.434,6.025-2.22,6.06-4.774v-9.788v0.084 c-0.062-7.879,5.311-3.858,5.311-3.858l23.346,22.95c1.842,1.843,6.8,3.308,9.362,0.711C53.583,47.516,49.821,43.637,47.979,41.795 z"></path>
25
- <path d="M0.755,26.555c0,0,0.024-0.099,0-0.277v-0.004V26.555z"></path>
26
- </g>
27
- <g className="arrow" transform={!isFullscreen ? '' : "translate(0, 0) rotate(180 100 30)"}>
28
- <path d="M89.483,50.518l21.504-21.512c6.034-3.995,6.07,6.546,6.07,6.546v6.385c0.104,4.055,2.361,6.281,5.228,6.24 c2.867-0.04,5.217-1.59,5.152-5.167V26.219c1.266-24.08-16.521-23.337-20.645-22.924c-0.206,0.02-0.374-0.015-0.503,0h-0.024 l-15.21,0.011c-2.557-0.029-5.834,1.211-6.265,4.501c-0.436,3.329,2.219,6.025,4.773,6.06h9.789H99.27 c7.879-0.062,3.858,5.311,3.858,5.311L80.177,42.524c-1.842,1.842-3.309,6.801-0.711,9.363 C83.764,56.123,87.642,52.362,89.483,50.518z"></path>
29
- <path d="M104.723,3.294c0,0,0.101,0.024,0.279,0h0.003H104.723z"></path>
30
- </g>
31
- <g className="arrow" transform={!isFullscreen ? '' : "translate(0, 0) rotate(180 100 100)"}>
32
- <path d="M80.759,88.376l21.514,21.505c3.995,6.035-6.546,6.068-6.546,6.068H89.34c-4.054,0.106-6.282,2.364-6.24,5.23 c0.041,2.863,1.591,5.214,5.167,5.149h16.792c24.08,1.269,23.337-16.521,22.924-20.642c-0.02-0.21,0.017-0.377,0-0.503v-0.025 l-0.012-15.21c0.031-2.557-1.209-5.834-4.501-6.265c-3.327-0.436-6.023,2.219-6.06,4.772v9.79v-0.084 c0.062,7.879-5.312,3.856-5.312,3.856L88.753,79.068c-1.843-1.841-6.8-3.308-9.362-0.709 C75.153,82.656,78.916,86.534,80.759,88.376z"></path>
33
- <path d="M127.982,103.617c0,0-0.022,0.098,0,0.276v0.006V103.617z"></path>
34
- </g>
35
- <g className="arrow" transform={!isFullscreen ? '' : "translate(0, 0) rotate(180 30 100)"}>
36
- <path d="M43.481,79.65l-21.503,21.514c-6.035,3.995-6.07-6.547-6.07-6.547v-6.384c-0.104-4.054-2.362-6.283-5.229-6.241 c-2.865,0.041-5.215,1.592-5.151,5.168v16.792c-1.267,24.078,16.521,23.338,20.643,22.924c0.208-0.02,0.375,0.015,0.503,0h0.025 l15.21-0.011c2.557,0.028,5.833-1.213,6.264-4.501c0.436-3.33-2.219-6.026-4.773-6.06h-9.789h0.084 c-7.879,0.062-3.857-5.312-3.857-5.312l22.949-23.347c1.843-1.844,3.31-6.8,0.711-9.363C49.201,74.045,45.323,77.809,43.481,79.65z "></path>
37
- <path d="M28.242,126.876c0,0-0.1-0.024-0.278,0h-0.004H28.242z"></path>
38
- </g>
39
- </svg>
40
- </div>
41
- )}
42
- <div className="btn refresh-btn" onClick={() => vm.refreshBtnClick()}>
43
- <svg id="Capa_1" x="0px" y="0px" viewBox="0 0 305.836 305.836" ref={vm.elements.refreshIcon as Ref<SVGSVGElement>}>
44
- <title>Refresh Data</title>
45
- <g>
46
- <path d="M152.924,300.748c84.319,0,152.912-68.6,152.912-152.918c0-39.476-15.312-77.231-42.346-105.564 c0,0,3.938-8.857,8.814-19.783c4.864-10.926-2.138-18.636-15.648-17.228l-79.125,8.289c-13.511,1.411-17.999,11.467-10.021,22.461 l46.741,64.393c7.986,10.992,17.834,12.31,22.008,2.937l7.56-16.964c12.172,18.012,18.976,39.329,18.976,61.459 c0,60.594-49.288,109.875-109.87,109.875c-60.591,0-109.882-49.287-109.882-109.875c0-19.086,4.96-37.878,14.357-54.337 c5.891-10.325,2.3-23.467-8.025-29.357c-10.328-5.896-23.464-2.3-29.36,8.031C6.923,95.107,0,121.27,0,147.829 C0,232.148,68.602,300.748,152.924,300.748z" />
47
- </g>
48
- </svg>
49
- </div>
50
- </section>
51
- <section className="page-section">
52
- <section className="page-size-section" title={vm.i18n.messages!.pageItemCount}>
53
- <select value={vm.config.page.size} className="page-size-select" onChange={(e) => vm.onPageSizeChange(e)}>
54
- <option value={20}>{vm.paginationDisplayNumbers.pageSizes[0]}</option>
55
- <option value={30}>{vm.paginationDisplayNumbers.pageSizes[1]}</option>
56
- <option value={50}>{vm.paginationDisplayNumbers.pageSizes[2]}</option>
57
- <option value={100}>{vm.paginationDisplayNumbers.pageSizes[3]}</option>
58
- </select>
59
- </section>
60
- <section className="items-information-section">
61
- <span>{vm.paginationDisplayNumbers.startItemIndex}</span>
62
- <span>-</span>
63
- <span> {vm.paginationDisplayNumbers.endItemIndex} </span>
64
- <span> &nbsp;{vm.i18n.messages!.from}</span>
65
- <span title={vm.i18n.messages!.currentAvailableItem}>&nbsp; {vm.paginationDisplayNumbers.totalItemsCount} &nbsp;</span>
66
-
67
- </section>
68
- <section className="navigation-section nav-btn">
69
- <nav>
70
- <JBPagination pageIndex={vm.config.page.index} max={vm.config.page.totalPages} min={1} onChange={(e)=>vm.goToPage((e.target as JBPaginationWebComponent).pageIndex)} showPersianNumber={vm.i18n.showPersianNumber}/>
71
- </nav>
72
- </section>
73
- </section>
74
-
75
- </section>
76
- );
77
- }
78
-
79
- export default observer(Footer) ;
1
+ import React from 'react';
2
+ import type JBGridViewModel from './JBGridViewModel.js';
3
+ import CSS from './footer.css?inline';
4
+ import { injectCss } from 'jb-core';
5
+ import { JBFullscreenIcon, JBPagination, JBPaginationInfo, JBRefreshIcon } from './JBGrid.js';
6
+ import type { JBPaginationWebComponent } from 'jb-grid';
7
+ import { JBButton } from 'jb-button/react';
8
+ injectCss(CSS as unknown as string);
9
+ type FooterProps = {
10
+ vm:JBGridViewModel,
11
+ isFullscreen:boolean
12
+ }
13
+ function Footer(props:FooterProps) {
14
+ const {vm,isFullscreen} = props;
15
+ return (
16
+ <section key={'jb-grid-footer'} className="jb-grid-footer">
17
+ <section className="btn-wrapper-section">
18
+ {
19
+ isFullscreen !== null && isFullscreen !== undefined && (
20
+ <JBButton className="btn full-screen-button" variant="text" onClick={() => vm.onFullScreenBtnClicked(isFullscreen)}>
21
+ <JBFullscreenIcon state={isFullscreen ? "exit" : "enter"} />
22
+ </JBButton>
23
+ )}
24
+ <JBButton className="btn refresh-btn" variant="text" onClick={() => vm.refreshBtnClick()}>
25
+ <JBRefreshIcon ref={vm.elements.refreshIcon} />
26
+ </JBButton>
27
+ </section>
28
+ <section className="page-section">
29
+ <JBPaginationInfo
30
+ pageSize={vm.page.size}
31
+ pageSizes={[20, 30, 50, 100]}
32
+ startItemIndex={vm.metaData.startItemIndex}
33
+ endItemIndex={vm.metaData.endItemIndex}
34
+ totalItemsCount={vm.metaData.totalItemsCount}
35
+ pageItemCountTitle={vm.i18n.messages!.pageItemCount}
36
+ fromLabel={vm.i18n.messages!.from}
37
+ currentAvailableItemTitle={vm.i18n.messages!.currentAvailableItem}
38
+ showPersianNumber={vm.i18n.showPersianNumber}
39
+ onPageSizeChange={(e) => vm.setPageSize(e.detail.pageSize)}
40
+ />
41
+ <section className="navigation-section nav-btn">
42
+ <nav>
43
+ <JBPagination pageIndex={vm.page.index} max={vm.page.totalPages} min={1} onChange={(e)=>vm.goToPage((e.target as JBPaginationWebComponent).pageIndex)} showPersianNumber={vm.i18n.showPersianNumber}/>
44
+ </nav>
45
+ </section>
46
+ </section>
47
+
48
+ </section>
49
+ );
50
+ }
51
+
52
+ export default Footer;
@@ -1,35 +1,21 @@
1
1
  import React, { ReactNode } from 'react';
2
- import JBGridViewModel from './JBGridViewModel.js';
3
- import { JBSearchbarWebComponent } from 'jb-searchbar';
4
- import 'jb-searchbar/react/lib/module-declaration.js';
5
- import { observer } from 'mobx-react';
6
- import CSS from './header.css';
2
+ import type JBGridViewModel from './JBGridViewModel.js';
3
+ import CSS from './header.css?inline';
7
4
  import { injectCss } from 'jb-core';
8
5
 
9
6
  injectCss(CSS as unknown as string);
10
7
 
11
8
  type HeaderProps = {
12
- vm: JBGridViewModel<any>,
9
+ vm: JBGridViewModel,
13
10
  title: string,
14
- searchbarConfig: any,
11
+ searchbarComponent?: ReactNode,
15
12
  headerEndComponents?: React.ReactNode[] | ReactNode
16
13
  }
17
- declare global {
18
- // eslint-disable-next-line @typescript-eslint/no-namespace
19
- namespace JSX {
20
- interface IntrinsicElements {
21
- 'jb-searchbar': JBSearchbarType;
22
- }
23
- interface JBSearchbarType extends React.DetailedHTMLProps<React.HTMLAttributes<JBSearchbarWebComponent>, JBSearchbarWebComponent> {
24
- class?: string,
25
- }
26
- }
27
- }
28
14
  function Header(props: HeaderProps) {
29
15
  const { vm } = props;
30
16
  return (
31
17
  <section key={'jb-grid-header'} className="jb-grid-header">
32
- <section className={"main-section " + (vm.config.states.headerSection == "MAIN" ? "" : "hidden")}>
18
+ <section className={`main-section ${vm.headerSection == "MAIN" ? "" : "hidden"}`}>
33
19
  <section className="jb-grid-title">{props.title}</section>
34
20
  <section className="button-container">
35
21
  {
@@ -44,9 +30,10 @@ function Header(props: HeaderProps) {
44
30
  }
45
31
  {
46
32
 
47
- props.searchbarConfig && (
33
+ props.searchbarComponent && (
48
34
  <div className="filter-btn btn" onClick={() => { vm.openSearchHeaderSection(); }}>
49
35
  <svg xmlns="http://www.w3.org/2000/svg" height="30" viewBox="0 0 24 24" fill="none">
36
+ <title>filter button</title>
50
37
  <g>
51
38
  <path d="M4.00001 3C3.62123 3 3.27497 3.214 3.10558 3.55279C2.93619 3.89157 2.97274 4.29698 3.20001 4.6L8.80001 12.0667C8.92983 12.2398 9.00001 12.4503 9.00001 12.6667V20C9.00001 20.3466 9.17946 20.6684 9.47427 20.8507C9.76909 21.0329 10.1372 21.0494 10.4472 20.8944L14.4472 18.8944C14.786 18.725 15 18.3788 15 18V12.6667C15 12.4503 15.0702 12.2398 15.2 12.0667L20.8 4.6C21.0273 4.29698 21.0638 3.89157 20.8944 3.55279C20.725 3.214 20.3788 3 20 3H4.00001Z" />
52
39
  </g>
@@ -55,17 +42,17 @@ function Header(props: HeaderProps) {
55
42
  )}
56
43
  </section>
57
44
  </section>
58
- <section className={"search-section " + (vm.config.states.headerSection == "SEARCH" ? "" : "hidden")}>
45
+ <section className={`search-section ${vm.headerSection == "SEARCH" ? "" : "hidden"}`}>
59
46
  <div className="close-btn" onClick={() => { vm.openMainHeaderSection(); }}>
60
47
  <svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 224.512 224.512">
48
+ <title>close filter button</title>
61
49
  <g>
62
50
  <polygon points="224.507,6.997 217.521,0 112.256,105.258 6.998,0 0.005,6.997 105.263,112.254 0.005,217.512 6.998,224.512 112.256,119.24 217.521,224.512 224.507,217.512 119.249,112.254 " />
63
51
  </g>
64
52
  </svg>
65
53
  </div>
66
54
  <div className="search-bar-wrapper">{
67
- props.searchbarConfig &&
68
- <jb-searchbar ref={vm.elements.searchbar}></jb-searchbar>
55
+ props.searchbarComponent
69
56
  }
70
57
  </div>
71
58
  </section>
@@ -73,4 +60,4 @@ function Header(props: HeaderProps) {
73
60
  );
74
61
  }
75
62
 
76
- export default observer(Header);
63
+ export default Header;