jb-grid 0.2.3 → 0.3.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 (35) hide show
  1. package/README.md +46 -1
  2. package/package.json +4 -3
  3. package/react/dist/Components/Cell.d.ts +8 -7
  4. package/react/dist/Components/ExpandRow.d.ts +4 -6
  5. package/react/dist/Components/ExpandToggle.d.ts +5 -0
  6. package/react/dist/Components/Pagination.d.ts +4 -22
  7. package/react/dist/Components/Row.d.ts +10 -4
  8. package/react/dist/Components/module-declaration.d.ts +19 -0
  9. package/react/dist/Components/types.d.ts +9 -0
  10. package/react/dist/JBGrid.cjs.js +1 -1
  11. package/react/dist/JBGrid.cjs.js.map +1 -1
  12. package/react/dist/JBGrid.d.ts +6 -5
  13. package/react/dist/JBGrid.js +1 -1
  14. package/react/dist/JBGrid.js.map +1 -1
  15. package/react/dist/JBGrid.umd.js +1 -1
  16. package/react/dist/JBGrid.umd.js.map +1 -1
  17. package/react/dist/JBGridData.d.ts +1 -1
  18. package/react/dist/JBGridViewModel.d.ts +6 -6
  19. package/react/dist/types.d.ts +2 -2
  20. package/react/lib/Components/Cell.tsx +10 -17
  21. package/react/lib/Components/ExpandRow.tsx +5 -14
  22. package/react/lib/Components/ExpandToggle.tsx +10 -0
  23. package/react/lib/Components/Pagination.tsx +5 -21
  24. package/react/lib/Components/Row.tsx +11 -17
  25. package/react/lib/Components/module-declaration.ts +20 -0
  26. package/react/lib/Components/types.ts +10 -0
  27. package/react/lib/Content.tsx +1 -1
  28. package/react/lib/Footer.tsx +3 -3
  29. package/react/lib/JBGrid.tsx +9 -6
  30. package/react/lib/JBGridViewModel.ts +16 -16
  31. package/react/lib/types.ts +2 -2
  32. package/react/package.json +1 -1
  33. package/react/tsconfig.json +1 -1
  34. package/react/lib/Components/expand-row.css +0 -38
  35. package/react/lib/Components/row.css +0 -25
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # jb-grid
2
2
 
3
- > currently this component only available in react in full mode and web-component is only support parts of the data grid like pagination.
3
+ > currently this component only available in react in full mode and web-component is only support parts of the data grid like pagination adn Row, Cell.
4
4
 
5
5
  ## using with JS frameworks
6
6
 
@@ -21,5 +21,50 @@ document.querySelector(`jb-pagination`).pageIndex = 5;
21
21
  document.querySelector(`jb-pagination`).max = 10;
22
22
  //min page number default is 1
23
23
  document.querySelector(`jb-pagination`).min = 0;
24
+ ```
25
+
26
+ ## Row & Cells
27
+ `jb-row` is a row web-component that imply a grid template base on given config to below cells. it also accept expand row that you can open and close it.
28
+
29
+ here is a code overview:
30
+ ```html
31
+ <jb-row>
32
+ <jb-cell name="id">123<jb-cell>
33
+ <jb-cell name="name">Joe<jb-cell>
34
+ <jb-cell name="age">10<jb-cell>
35
+ <jb-cell name="operation"><jb-expand-toggle><button>toggle</button></jb-expand-toggle><jb-cell>
36
+ <div slot="expand">expand window content</div>
37
+ </jb-row>
38
+ ```
39
+ ### Set Column Size
24
40
 
41
+ to set column size of the row you can pass a config that tell each column size. remember size is optional(default is `1fr`) but name is mandatory.
42
+ ```js
43
+ document.querySelector(""jb-row).rowTemplate = [
44
+ {name:"id",size:"1fr"},
45
+ {name:"name",size:"400px"},
46
+ {name:"age",size:200},
47
+ {name:"operation",size:20%},
48
+ ]
49
+ ```
50
+
51
+ ### expand row
52
+
53
+ each row can contain a expand panel that open by user choice to show more data about that row.
54
+ you must set `slot="expand"`in a div to make it as a expand div and set `isOpen` of row to open and close it or use `jb-expand-toggle` to do it automatically for you.
55
+
56
+ ```html
57
+ <jb-row>
58
+ <jb-cell name="id">123<jb-cell>
59
+ <jb-cell name="operation"><jb-expand-toggle><button>toggle</button></jb-expand-toggle><jb-cell>
60
+ <div slot="expand">expand window content</div>
61
+ </jb-row>
25
62
  ```
63
+ > `<jb-expand-toggle>`has a arrow icon designed to be put in first cell by default but you can customize it by passing children to it as you wish
64
+ if you want to close and open by js you can use js mode:
65
+ ```js
66
+ //to open it
67
+ document.querySelector(`jb-row`).isOpen = true;
68
+ // to close it
69
+ document.querySelector(`jb-row`).isOpen = false;
70
+ ```
package/package.json CHANGED
@@ -10,10 +10,11 @@
10
10
  "jb",
11
11
  "jb-grid",
12
12
  "table",
13
+ "pagination",
13
14
  "web component",
14
15
  "react component"
15
16
  ],
16
- "version": "0.2.3",
17
+ "version": "0.3.0",
17
18
  "bugs": "https://github.com/javadbat/jb-grid/issues",
18
19
  "license": "MIT",
19
20
  "files": [
@@ -31,9 +32,9 @@
31
32
  "url": "git@github.com:javadbat/jb-grid.git"
32
33
  },
33
34
  "dependencies": {
34
- "jb-core":">=0.19.0",
35
+ "jb-core":">=0.27.2",
35
36
  "mobx":">=6.0.0",
36
37
  "mobx-react":">=7.0.0",
37
- "jb-searchbar":">=2.6.0"
38
+ "jb-searchbar":">=3.0.2"
38
39
  }
39
40
  }
@@ -1,9 +1,10 @@
1
- import React from 'react';
2
- type CellProps = {
3
- children?: React.ReactNode | React.ReactNode[];
1
+ import React, { type ForwardedRef } from 'react';
2
+ import type { JBCellAttributes } from './module-declaration.js';
3
+ import type { JBCellWebComponent } from 'jb-grid';
4
+ type RowProps = JBCellAttributes & {
5
+ ref?: ForwardedRef<JBCellWebComponent | null>;
6
+ name: string;
4
7
  label?: string;
5
- className?: string;
6
- flex?: boolean;
7
8
  };
8
- declare function Cell(props: CellProps): React.JSX.Element;
9
- export { Cell };
9
+ export declare function JBCell(props: RowProps): React.JSX.Element;
10
+ export {};
@@ -1,6 +1,4 @@
1
- import React, { type PropsWithChildren } from 'react';
2
- declare function ExpandRow(props: Props): React.JSX.Element;
3
- type Props = PropsWithChildren<{
4
- show: boolean;
5
- }>;
6
- export { ExpandRow };
1
+ import React, { type HTMLAttributes, type PropsWithChildren } from 'react';
2
+ export declare function ExpandRow(props: Props): React.JSX.Element;
3
+ type Props = PropsWithChildren<React.DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
4
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { JBExpandToggleAttributes } from './module-declaration.js';
3
+ type ToggleProps = JBExpandToggleAttributes;
4
+ export declare function JBExpandToggle(props: ToggleProps): React.JSX.Element;
5
+ export {};
@@ -1,26 +1,8 @@
1
- import React, { type DetailedHTMLProps, type FormEventHandler, type HTMLAttributes } from 'react';
1
+ import React from 'react';
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
+ import type { JBPaginationDirectAttributeProps } from './types';
6
+ import './module-declaration.js';
12
7
  export declare function JBPagination(props: Props): React.JSX.Element;
13
- type JBPaginationAttributes = DetailedHTMLProps<HTMLAttributes<JBPaginationWebComponent>, JBPaginationWebComponent> & {
14
- pageIndex?: number;
15
- max?: number;
16
- min?: number;
17
- showPersianNumber?: boolean;
18
- };
19
- declare module "react" {
20
- namespace JSX {
21
- interface IntrinsicElements {
22
- 'jb-pagination': JBPaginationAttributes;
23
- }
24
- }
25
- }
26
- export {};
8
+ export type Props = JBElementStandardProps<JBPaginationWebComponent, keyof JBPaginationDirectAttributeProps> & JBPaginationDirectAttributeProps;
@@ -1,4 +1,10 @@
1
- import React from 'react';
2
- type RowProps = Omit<React.ComponentPropsWithoutRef<'div'>, "style">;
3
- declare function Row(props: RowProps): React.JSX.Element;
4
- export { Row };
1
+ import React, { type ForwardedRef } from 'react';
2
+ import type { JBRowAttributes } from './module-declaration.js';
3
+ import type { JBCellWebComponent, RowTemplate } from 'jb-grid';
4
+ type RowProps = JBRowAttributes & {
5
+ ref?: ForwardedRef<JBCellWebComponent | null>;
6
+ rowTemplate: RowTemplate;
7
+ isOpen?: boolean;
8
+ };
9
+ export declare function JBRow(props: RowProps): React.JSX.Element;
10
+ export {};
@@ -0,0 +1,19 @@
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
+ export type JBExpandToggleAttributes = DetailedHTMLProps<HTMLAttributes<JBExpandToggleWebComponent>, JBExpandToggleWebComponent>;
9
+ declare module "react" {
10
+ namespace JSX {
11
+ interface IntrinsicElements {
12
+ 'jb-pagination': JBPaginationAttributes;
13
+ 'jb-row': JBRowAttributes;
14
+ 'jb-cell': JBCellAttributes;
15
+ 'jb-expand-toggle': JBExpandToggleAttributes;
16
+ }
17
+ }
18
+ }
19
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { JBPaginationWebComponent } from "jb-grid";
2
+ import type { FormEventHandler } from "react";
3
+ export type JBPaginationDirectAttributeProps = {
4
+ pageIndex?: number;
5
+ max?: number;
6
+ min?: number;
7
+ onChange?: FormEventHandler<JBPaginationWebComponent>;
8
+ showPersianNumber?: boolean;
9
+ };