jb-grid 0.2.3 → 0.2.4

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.
@@ -2,24 +2,13 @@ import React, { type DetailedHTMLProps, type FormEventHandler, type HTMLAttribut
2
2
  import 'jb-grid'
3
3
  import type {JBPaginationWebComponent} from 'jb-grid'
4
4
  import type { JBElementStandardProps } from 'jb-core/react';
5
- export type Props = JBElementStandardProps & {
6
- pageIndex?:number,
7
- max?:number,
8
- min?:number,
9
- onChange?:FormEventHandler<JBPaginationWebComponent>
10
- showPersianNumber?:boolean,
11
- }
5
+
12
6
  export function JBPagination(props:Props){
13
7
  const {pageIndex, max, min, onChange,showPersianNumber, ...otherProps } = props;
14
8
  return(<jb-pagination pageIndex={pageIndex} max={max} min={min} onChange={onChange} showPersianNumber={showPersianNumber} {...otherProps}></jb-pagination>)
15
9
  }
16
10
 
17
- type JBPaginationAttributes = DetailedHTMLProps<HTMLAttributes<JBPaginationWebComponent>, JBPaginationWebComponent> & {
18
- pageIndex?:number
19
- max?:number
20
- min?:number,
21
- showPersianNumber?:boolean,
22
- }
11
+ type JBPaginationAttributes = DetailedHTMLProps<HTMLAttributes<JBPaginationWebComponent>, JBPaginationWebComponent> & DirectAttributeProps
23
12
  declare module "react" {
24
13
  // eslint-disable-next-line @typescript-eslint/no-namespace
25
14
  namespace JSX {
@@ -27,4 +16,14 @@ declare module "react" {
27
16
  'jb-pagination': JBPaginationAttributes;
28
17
  }
29
18
  }
30
- }
19
+ }
20
+
21
+ type DirectAttributeProps = {
22
+ pageIndex?:number,
23
+ max?:number,
24
+ min?:number,
25
+ onChange?:FormEventHandler<JBPaginationWebComponent>
26
+ showPersianNumber?:boolean,
27
+ }
28
+
29
+ export type Props = JBElementStandardProps<JBPaginationWebComponent, keyof DirectAttributeProps> & DirectAttributeProps
@@ -1,17 +1,17 @@
1
- import React, { ReactNode, useEffect } from 'react';
1
+ import React, { type ReactNode, useEffect } from 'react';
2
2
  import JBGridViewModel, { JBGridContext } from './JBGridViewModel.js';
3
3
  import { observer } from 'mobx-react';
4
4
  import CSS from './jb-grid.css';
5
5
  export { JBGridData } from './JBGridData.js';
6
6
  import 'jb-searchbar';
7
- import { AnyObject, JBGridBridgeClassInterface, JBGridConfig, JBGridI18nConfig, SearchbarConfig } from './types.js';
7
+ import type { AnyObject, JBGridBridgeClassInterface, JBGridConfig, JBGridI18nConfig, SearchbarConfig } from './types.js';
8
8
  import Footer from './Footer.js';
9
9
  import Header from './Header.js';
10
10
  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
+ export {JBPagination, type Props as PaginationProps} from './Components/Pagination.js';
15
15
  export { Row } from './Components/Row.js';
16
16
  export { Cell } from './Components/Cell.js';
17
17
  export { ExpandRow } from './Components/ExpandRow.js';
@@ -55,7 +55,7 @@ function JBGridComponent<T extends AnyObject>(props: Props<T>) {
55
55
  }
56
56
  return (
57
57
  <JBGridContext.Provider value={vm} key={"jb-grid-context"}>
58
- <div className={"jb-grid-wrapper " + (props.className ?? "")} ref={vm.JBGridComponentDom} style={props.style}>
58
+ <div className={`jb-grid-wrapper ${props.className ?? ""}`} ref={vm.JBGridComponentDom} style={props.style}>
59
59
  <Header title={props.title} vm={vm} searchbarConfig={props.searchbarConfig} headerEndComponents={props.headerEndComponents}></Header>
60
60
  <Content i18n={vm.i18n} config={vm.config} isErrorOccurred={vm.isErrorOccurred} isLoading={vm.isLoading} refreshBtnClick={vm.refreshBtnClick} setSortColumn={vm.setSortColumn} styles={vm.styles} errorComponent={props.contentError}>{props.children}</Content>
61
61
  <Footer isFullscreen={props.isFullscreen ?? false} vm={vm}></Footer>
@@ -1,4 +1,4 @@
1
- import React, { createContext, useContext, type Ref, type RefObject } from 'react';
1
+ import React, { createContext, useContext, type RefObject } from 'react';
2
2
  import { observable, extendObservable, makeObservable, action, computed } from 'mobx';
3
3
  import type { ActionDispatchers, AnyObject, JBGridBridgeClassInterface, JBGridBridgeInterface, JBGridCallbacks, JBGridColumnDef, JBGridConfig, JBGridConfigInterface, JBGridFilter, JBGridI18nConfig, JBGridResponseData, JBGridRowData, JBGridRowDetail, JBGridStyles, SearchbarConfig } from './types.js';
4
4
  import type { JBSearchbarWebComponent, JBSearchbarValue } from 'jb-searchbar';
@@ -155,15 +155,15 @@ class JBGridViewModel<T extends AnyObject> {
155
155
  InitSize() {
156
156
  //init table width column
157
157
  const scrollWidth = this.getScrollbarWidth();
158
- this.styles.table.scrollIndent.width = 'calc(100% - ' + scrollWidth + 'px)';
158
+ this.styles.table.scrollIndent.width = `calc(100% - ${scrollWidth}px)`;
159
159
  //config css grid for table layout
160
160
  let gridTemplateColumns = "";
161
- this.config.table.columns.map((item) => {
161
+ this.config.table.columns.forEach((item) => {
162
162
  if (item.width != null || item.width != undefined) {
163
163
  if (typeof (item.width) == "number") {
164
- gridTemplateColumns += ' ' + item.width + 'px';
164
+ gridTemplateColumns += ` ${item.width}px`;
165
165
  } else {
166
- gridTemplateColumns += ' ' + item.width;
166
+ gridTemplateColumns += ` ${item.width}`;
167
167
  }
168
168
 
169
169
  } else {