jb-grid 0.1.0 → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  import React, { type RefObject } from 'react';
2
- import { AnyObject, JBGridBridgeClassInterface, JBGridBridgeInterface, JBGridCallbacks, JBGridColumnDef, JBGridConfig, JBGridConfigInterface, JBGridFilter, JBGridI18nConfig, JBGridResponseData, JBGridRowData, JBGridStyles, SearchbarConfig } from './types.js';
3
- import { JBSearchbarWebComponent, type JBSearchbarValue } from 'jb-searchbar';
2
+ import type { AnyObject, JBGridBridgeClassInterface, JBGridBridgeInterface, JBGridCallbacks, JBGridColumnDef, JBGridConfig, JBGridConfigInterface, JBGridFilter, JBGridI18nConfig, JBGridResponseData, JBGridRowData, JBGridStyles, SearchbarConfig } from './types.js';
3
+ import type { JBSearchbarWebComponent, JBSearchbarValue } from 'jb-searchbar';
4
4
  declare class JBGridViewModel<T extends AnyObject> {
5
5
  styles: JBGridStyles;
6
6
  elements: {
@@ -30,9 +30,6 @@ declare class JBGridViewModel<T extends AnyObject> {
30
30
  onFetchSuccess(data: JBGridResponseData<T>): void;
31
31
  standardData(data: AnyObject[]): Promise<JBGridRowData<T>[]>;
32
32
  CreateRequestBody(): any;
33
- goToNextPage(): void;
34
- goToPrevPage(): void;
35
- goToLastPage(): void;
36
33
  goToFirstPage(): void;
37
34
  refreshBtnClick(): void;
38
35
  playRefreshBtnAnimation(): Animation;
@@ -0,0 +1,29 @@
1
+ import React, { type DetailedHTMLProps, type FormEventHandler, type HTMLAttributes } from 'react';
2
+ import 'jb-grid'
3
+ import type {JBPaginationWebComponent} from 'jb-grid'
4
+ export type Props = {
5
+ pageIndex?:number,
6
+ max?:number,
7
+ min?:number,
8
+ onChange?:FormEventHandler<JBPaginationWebComponent>
9
+ showPersianNumber?:boolean,
10
+ }
11
+ export function JBPagination(props:Props){
12
+ const {pageIndex, max, min, onChange,showPersianNumber} = props;
13
+ return(<jb-pagination pageIndex={pageIndex} max={max} min={min} onChange={onChange} showPersianNumber={showPersianNumber}></jb-pagination>)
14
+ }
15
+
16
+ type JBPaginationAttributes = DetailedHTMLProps<HTMLAttributes<JBPaginationWebComponent>, JBPaginationWebComponent> & {
17
+ pageIndex?:number
18
+ max?:number
19
+ min?:number,
20
+ showPersianNumber?:boolean,
21
+ }
22
+ declare module "react" {
23
+ // eslint-disable-next-line @typescript-eslint/no-namespace
24
+ namespace JSX {
25
+ interface IntrinsicElements {
26
+ 'jb-pagination': JBPaginationAttributes;
27
+ }
28
+ }
29
+ }
@@ -1,8 +1,10 @@
1
1
  import { observer } from 'mobx-react';
2
2
  import React, { type Ref } from 'react';
3
- import JBGridViewModel from './JBGridViewModel.js';
3
+ import type JBGridViewModel from './JBGridViewModel.js';
4
4
  import CSS from './footer.css';
5
5
  import { injectCss } from 'jb-core';
6
+ import { JBPagination } from './JBGrid.js';
7
+ import type { JBPaginationWebComponent } from '../../web-component/dist/index.js';
6
8
  injectCss(CSS as unknown as string);
7
9
  type FooterProps = {
8
10
  vm:JBGridViewModel<any>,
@@ -17,6 +19,7 @@ function Footer(props:FooterProps) {
17
19
  isFullscreen !== null && isFullscreen !== undefined && (
18
20
  <div className="btn full-screen-button" onClick={() => vm.onFullScreenBtnClicked(isFullscreen)}>
19
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>
20
23
  <g className="arrow" transform={!isFullscreen ? '' : "translate(0, 0) rotate(180 30 30)"}>
21
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>
22
25
  <path d="M0.755,26.555c0,0,0.024-0.099,0-0.277v-0.004V26.555z"></path>
@@ -38,6 +41,7 @@ function Footer(props:FooterProps) {
38
41
  )}
39
42
  <div className="btn refresh-btn" onClick={() => vm.refreshBtnClick()}>
40
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>
41
45
  <g>
42
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" />
43
47
  </g>
@@ -63,30 +67,7 @@ function Footer(props:FooterProps) {
63
67
  </section>
64
68
  <section className="navigation-section nav-btn">
65
69
  <nav>
66
- <div className="last-Page-btn nav-btn" title={vm.config.page.totalPages.toString()} onClick={() => vm.goToLastPage()}>
67
- <svg width="100%" height="100%" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet"><path d="M15 6 v12 h2 v-12 h-2z M8 6L6.59 7.41 11.17 12l-4.58 4.59L8 18l6-6z"></path></svg>
68
-
69
- </div>
70
- <div className="next-Page-btn nav-btn" onClick={() => vm.goToNextPage()}>
71
- <svg width="100%" height="100%" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></svg>
72
-
73
- </div>
74
- <div className="number-container">
75
- <div className="number-wrapper">
76
- <div className="number-btn" onClick={() => vm.goToPage(vm.config.page.index + 2)}>{vm.paginationDisplayNumbers.next2Page}</div>
77
- <div className="number-btn" onClick={() => vm.goToPage(vm.config.page.index + 1)}>{vm.paginationDisplayNumbers.nextPage}</div>
78
- <div className="number-btn current-page" onClick={() => vm.changePageNumberToInput()}>{vm.paginationDisplayNumbers.currentPage}</div>
79
- <div className="number-btn" onClick={() => vm.goToPage(vm.config.page.index - 1)}>{vm.paginationDisplayNumbers.prevPage}</div>
80
- <div className="number-btn" onClick={() => vm.goToPage(vm.config.page.index - 2)}>{vm.paginationDisplayNumbers.prev2Page}</div>
81
- </div>
82
- </div>
83
- <div className="prev-Page-btn nav-btn" onClick={() => vm.goToPrevPage()}>
84
- <svg width="100%" height="100%" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path></svg>
85
- </div>
86
- <div className="first-Page-btn nav-btn" onClick={() => vm.goToFirstPage()}>
87
- <svg width="100%" height="100%" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet"><path d="M7 6 v12 h2 v-12 h-2z M17.41 7.41L16 6l-6 6 6 6 1.41-1.41L12.83 12z"></path></svg>
88
-
89
- </div>
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}/>
90
71
  </nav>
91
72
  </section>
92
73
  </section>
@@ -3,7 +3,7 @@ import JBGridViewModel from './JBGridViewModel.js';
3
3
  import { JBSearchbarWebComponent } from 'jb-searchbar';
4
4
  import 'jb-searchbar/react/lib/module-declaration.js';
5
5
  import { observer } from 'mobx-react';
6
- import CSS from './Header.css';
6
+ import CSS from './header.css';
7
7
  import { injectCss } from 'jb-core';
8
8
 
9
9
  injectCss(CSS as unknown as string);
@@ -11,6 +11,7 @@ import Content from './Content.js';
11
11
  import { useInstance } from 'jb-core/react';
12
12
  import { injectCss } from 'jb-core';
13
13
 
14
+ export {JBPagination, Props as PaginationProps} from './Components/Pagination.js';
14
15
  export { Row } from './Components/Row.js';
15
16
  export { Cell } from './Components/Cell.js';
16
17
  export { ExpandRow } from './Components/ExpandRow.js';
@@ -1,7 +1,7 @@
1
1
  import React, { createContext, useContext, type Ref, type RefObject } from 'react';
2
2
  import { observable, extendObservable, makeObservable, action, computed } from 'mobx';
3
- import { ActionDispatchers, AnyObject, JBGridBridgeClassInterface, JBGridBridgeInterface, JBGridCallbacks, JBGridColumnDef, JBGridConfig, JBGridConfigInterface, JBGridFilter, JBGridI18nConfig, JBGridResponseData, JBGridRowData, JBGridRowDetail, JBGridStyles, SearchbarConfig } from './types.js';
4
- import { JBSearchbarWebComponent, type JBSearchbarValue } from 'jb-searchbar';
3
+ import type { ActionDispatchers, AnyObject, JBGridBridgeClassInterface, JBGridBridgeInterface, JBGridCallbacks, JBGridColumnDef, JBGridConfig, JBGridConfigInterface, JBGridFilter, JBGridI18nConfig, JBGridResponseData, JBGridRowData, JBGridRowDetail, JBGridStyles, SearchbarConfig } from './types.js';
4
+ import type { JBSearchbarWebComponent, JBSearchbarValue } from 'jb-searchbar';
5
5
  import { defaultI18n } from './i18n.js';
6
6
  import { assign } from 'lodash';
7
7
  class JBGridViewModel<T extends AnyObject> {
@@ -60,7 +60,6 @@ class JBGridViewModel<T extends AnyObject> {
60
60
  filter: observable,
61
61
  exitFullScreenGrid: action,
62
62
  fullScreenGrid: action,
63
- goToLastPage: action,
64
63
  fetchGridData: action,
65
64
  initFilter: action.bound,
66
65
  InitSize: action.bound,
@@ -264,28 +263,6 @@ class JBGridViewModel<T extends AnyObject> {
264
263
  const requestBody = this.dataBridge.createRequestBody(this.config.page, this.filter.value, sortColumn, this.config.data);
265
264
  return requestBody;
266
265
  }
267
-
268
- goToNextPage() {
269
- const currentPage = this.config.page.index;
270
- if (currentPage < this.config.page.totalPages) {
271
- this.goToPage(currentPage + 1);
272
- }
273
-
274
- }
275
- goToPrevPage() {
276
- const currentPage = this.config.page.index;
277
- if (currentPage > 1) {
278
- this.goToPage(currentPage - 1);
279
- }
280
-
281
- }
282
- goToLastPage() {
283
- const currentPage = this.config.page.index;
284
- if (currentPage != this.config.page.totalPages) {
285
- this.goToPage(this.config.page.totalPages);
286
- }
287
-
288
- }
289
266
  goToFirstPage() {
290
267
  const currentPage = this.config.page.index;
291
268
  if (currentPage != 1) {
@@ -16,7 +16,7 @@
16
16
  "react",
17
17
  "mobx"
18
18
  ],
19
- "version": "0.21.0",
19
+ "version": "0.22.0",
20
20
  "bugs": "https://github.com/javadbat/jb-grid/issues",
21
21
  "license": "MIT",
22
22
  "files": [