mobigrid-module 1.1.25 → 1.1.31

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 CHANGED
@@ -2,42 +2,187 @@
2
2
 
3
3
  A flexible and customizable data table interface module with advanced filtering, column management, and action handling capabilities.
4
4
 
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install mobigrid-module
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ You can use the `MobigridModule` component by importing it into your React application.
14
+
15
+ ```tsx
16
+ import MobigridModule from 'mobigrid-module';
17
+ import 'mobigrid-module/dist/index.css'; // Import styles if necessary
18
+
19
+ function App() {
20
+ const handleEdit = (row) => {
21
+ console.log('Edit row:', row);
22
+ };
23
+
24
+ const handleDelete = (row) => {
25
+ console.log('Delete row:', row);
26
+ };
27
+
28
+ const checkEditPermission = (row) => {
29
+ return row.status !== 'LOCKED';
30
+ };
31
+
32
+ return (
33
+ <MobigridModule
34
+ configUrl="https://api.example.com/config"
35
+ // OR provide configJson directly
36
+ // configJson={myConfigObject}
37
+ dataUrl="https://api.example.com/data"
38
+ callbacks={{
39
+ onEdit: handleEdit,
40
+ onDelete: handleDelete,
41
+ canEdit: checkEditPermission
42
+ }}
43
+ customHeaders={{
44
+ 'Authorization': 'Bearer token123'
45
+ }}
46
+ />
47
+ );
48
+ }
49
+ ```
50
+
51
+ ## Component Props
52
+
53
+ The `MobigridModule` accepts the following props:
54
+
55
+ | Prop | Type | Description |
56
+ |------|------|-------------|
57
+ | `configUrl` | `string` | URL to fetch the configuration JSON from. |
58
+ | `configJson` | `object` | Direct configuration object. Use this or `configUrl`. |
59
+ | `dataUrl` | `string` | URL to fetch the table data from. Overrides `data_url` in config. |
60
+ | `preJsUrl` | `string` | URL to fetch a JavaScript file to execute before rendering (e.g., for global functions). |
61
+ | `preJs` | `string` | Direct JavaScript code string to execute. |
62
+ | `callbacks` | `object` | An object containing functions referenced by action buttons or conditions. |
63
+ | `customHeaders` | `object` | Custom HTTP headers to include in API requests (data and config). |
64
+ | `itemsPerPage` | `number` | Number of items to display per page (default: 14). |
65
+ | `dateFormat` | `string` | Format string for dates in API requests (default: "MM-dd-yyyy HH:mm"). |
66
+ | `children` | `ReactNode` | Child components to render at the bottom of the module. |
67
+
5
68
  ## Configuration Structure
6
69
 
7
- The configuration object defines the structure and behavior of a data table interface. It includes filters, columns, actions, and other settings.
70
+ The configuration object defines the structure of the table, filters, and columns. You can provide this via the `configUrl` endpoint or directly via the `configJson` prop.
71
+
72
+ ```json
73
+ {
74
+ "title": "User Management",
75
+ "data_url": "https://api.example.com/users",
76
+ "Filters": [
77
+ [
78
+ {
79
+ "type": "Text",
80
+ "name": "search",
81
+ "label": "Search Users"
82
+ },
83
+ {
84
+ "type": "Select",
85
+ "name": "role",
86
+ "label": "Role",
87
+ "urlSource": "https://api.example.com/roles" // Dynamic options
88
+ }
89
+ ],
90
+ [
91
+ {
92
+ "type": "Date",
93
+ "name": "fromDate",
94
+ "label": "From Date"
95
+ },
96
+ {
97
+ "type": "Date",
98
+ "name": "toDate",
99
+ "label": "To Date"
100
+ }
101
+ ]
102
+ ],
103
+ "colomns": [ // Note: spelling is 'colomns' in current version
104
+ {
105
+ "title": "Name",
106
+ "key": "fullName",
107
+ "type": "text"
108
+ },
109
+ {
110
+ "title": "Status",
111
+ "key": "status",
112
+ "type": "status"
113
+ },
114
+ {
115
+ "title": "Created At",
116
+ "key": "createdAt",
117
+ "type": "date",
118
+ "pattern": "dd/MM/yyyy"
119
+ },
120
+ {
121
+ "title": "Actions",
122
+ "key": "ACTIONS_BUTTONS",
123
+ "actions": [
124
+ {
125
+ "label": "Edit",
126
+ "icon": "icon-edit",
127
+ "action": "onEdit",
128
+ "condition": "canEdit"
129
+ }
130
+ ]
131
+ }
132
+ ]
133
+ }
134
+ ```
135
+
136
+ ### Filters Configuration
137
+
138
+ Filters are defined as an array of arrays (rows of filters).
139
+
140
+ - **`type`**: The type of filter. Supported types:
141
+ - `"Text"`: Simple text input.
142
+ - `"Select"`: Dropdown menu. Use `urlSource` for dynamic options or `options` for static ones.
143
+ - `"Date"`: Date picker.
144
+ - **`name`**: The query parameter key that will be sent to the `data_url`.
145
+ - **`label`**: The label displayed for the filter.
146
+ - **`urlSource`**: (For `Select` type) URL to fetch options from. Expects an array of objects `{ label, value }`.
147
+ - **`options`**: (For `Select` type) Static array of options `{ label, value }`.
148
+
149
+ ### Columns Configuration (`colomns`)
150
+
151
+ Defines the table columns.
152
+
153
+ - **`title`**: Header text for the column.
154
+ - **`key`**: The key in the data object to display.
155
+ - **`type`**: formatting type.
156
+ - `"text"`: Default display.
157
+ - `"date"`: Formats date using `pattern` (default: `dd-MM-yyyy`).
158
+ - `"money"`: Formats as currency. Usage: `currency` prop required.
159
+ - `"status"`: Displays a colored badge based on status value (PENDING, PAID, CANCELLED, etc.).
160
+ - `"ACTIONS_BUTTONS"`: Special column for action buttons.
161
+ - **`scroll`**: If true, limits height and adds scrollbar for long content.
8
162
 
9
- ### Main Properties
163
+ ### Actions Configuration
10
164
 
11
- - **title**: The title of the configuration
12
- - **data_url**: API endpoint for fetching data
13
- - **Filters**: Array of filter groups for data filtering
14
- - **columns**: Defines the table columns and their properties
15
- - **extractColumns**: Columns used for data export
16
- - **detailsColumns**: Columns shown in detail view
165
+ For columns with `key: "ACTIONS_BUTTONS"`, you can define an `actions` array.
17
166
 
18
- ### Filter Types
167
+ - **`label`**: Text on the button.
168
+ - **`icon`**: Icon name (referenced from Feather icons, prefixed with `icon-`).
169
+ - **`action`**: The name of the callback function in the `callbacks` prop to execute on click. receives the row data.
170
+ - **`condition`**: (Optional) The name of the callback function in the `callbacks` prop to determine visibility. Receives row data and must return `boolean`.
19
171
 
20
- - **Select**: Dropdown with options (static or dynamic from urlSource)
21
- - **Text**: Basic text input
22
- - **Date**: Date picker input
23
- - **Export**: Export functionality
24
- - **Button**: Action buttons (e.g., search)
172
+ ## Development
25
173
 
26
- ### Column Properties
174
+ To build the project:
27
175
 
28
- - **title**: Column header text
29
- - **key**: Data field identifier
30
- - **type**: Data type (date, money, dropdown, etc.)
31
- - **pattern**: Format pattern (for dates)
32
- - **actions**: Available actions for dropdown columns
176
+ ```bash
177
+ npm run build
178
+ ```
33
179
 
34
- ### Additional Settings
180
+ To deploy (build, version bump, publish, and push):
35
181
 
36
- - **max_diff**: Maximum difference value
37
- - **pagesNum**: Number of pages
38
- - **service_path**: Service implementation path
39
- - **authorized_profiles**: Allowed user profile IDs
40
- - **modal_size**: Size of modal windows
41
- - **components**: Required component names
182
+ ```bash
183
+ # Default bump is patch
184
+ ./deploy.sh
42
185
 
43
- ## Example Configuration
186
+ # Specify bump type
187
+ ./deploy.sh minor
188
+ ```
@@ -3,6 +3,7 @@ interface TableProps {
3
3
  data: any[];
4
4
  columns: any[];
5
5
  isLoading: boolean;
6
+ callbacks: any;
6
7
  }
7
- export declare function CustomTable({ data, columns, isLoading }: TableProps): React.JSX.Element;
8
+ export declare function CustomTable({ data, columns, isLoading, callbacks, }: TableProps): React.JSX.Element;
8
9
  export {};
@@ -8,6 +8,8 @@ interface PageHeaderProps {
8
8
  count: number;
9
9
  isLoading: boolean;
10
10
  setCurrentPage: (page: number) => void;
11
+ handleOptionsSearch: (filter: any, search: string) => void;
12
+ optionsLoading: boolean;
11
13
  }
12
- export declare function PageHeader({ title, filters, setFilters, configFilters, onSearch, count, isLoading, setCurrentPage, }: PageHeaderProps): React.JSX.Element;
14
+ export declare function PageHeader({ title, filters, setFilters, configFilters, onSearch, count, isLoading, setCurrentPage, handleOptionsSearch, optionsLoading, }: PageHeaderProps): React.JSX.Element;
13
15
  export {};
@@ -0,0 +1,80 @@
1
+ import * as React from "react";
2
+ import { type DialogProps } from "@radix-ui/react-dialog";
3
+ declare const Command: React.ForwardRefExoticComponent<Omit<{
4
+ children?: React.ReactNode;
5
+ } & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement> | "key"> & {
6
+ ref?: React.Ref<HTMLDivElement>;
7
+ } & {
8
+ asChild?: boolean;
9
+ }, keyof React.HTMLAttributes<HTMLDivElement> | "asChild" | "key"> & {
10
+ label?: string;
11
+ shouldFilter?: boolean;
12
+ filter?: (value: string, search: string, keywords?: string[]) => number;
13
+ defaultValue?: string;
14
+ value?: string;
15
+ onValueChange?: (value: string) => void;
16
+ loop?: boolean;
17
+ disablePointerSelection?: boolean;
18
+ vimBindings?: boolean;
19
+ } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
20
+ declare const CommandDialog: ({ children, ...props }: DialogProps) => React.JSX.Element;
21
+ declare const CommandInput: React.ForwardRefExoticComponent<Omit<Omit<Pick<Pick<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof React.InputHTMLAttributes<HTMLInputElement>> & {
22
+ ref?: React.Ref<HTMLInputElement>;
23
+ } & {
24
+ asChild?: boolean;
25
+ }, "asChild" | "key" | keyof React.InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
26
+ value?: string;
27
+ onValueChange?: (search: string) => void;
28
+ } & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
29
+ declare const CommandList: React.ForwardRefExoticComponent<Omit<{
30
+ children?: React.ReactNode;
31
+ } & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement> | "key"> & {
32
+ ref?: React.Ref<HTMLDivElement>;
33
+ } & {
34
+ asChild?: boolean;
35
+ }, keyof React.HTMLAttributes<HTMLDivElement> | "asChild" | "key"> & {
36
+ label?: string;
37
+ } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
38
+ declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<{
39
+ children?: React.ReactNode;
40
+ } & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement> | "key"> & {
41
+ ref?: React.Ref<HTMLDivElement>;
42
+ } & {
43
+ asChild?: boolean;
44
+ }, keyof React.HTMLAttributes<HTMLDivElement> | "asChild" | "key"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
45
+ declare const CommandGroup: React.ForwardRefExoticComponent<Omit<{
46
+ children?: React.ReactNode;
47
+ } & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement> | "key"> & {
48
+ ref?: React.Ref<HTMLDivElement>;
49
+ } & {
50
+ asChild?: boolean;
51
+ }, keyof React.HTMLAttributes<HTMLDivElement> | "asChild" | "key">, "heading" | "value"> & {
52
+ heading?: React.ReactNode;
53
+ value?: string;
54
+ forceMount?: boolean;
55
+ } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
56
+ declare const CommandSeparator: React.ForwardRefExoticComponent<Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement> | "key"> & {
57
+ ref?: React.Ref<HTMLDivElement>;
58
+ } & {
59
+ asChild?: boolean;
60
+ }, keyof React.HTMLAttributes<HTMLDivElement> | "asChild" | "key"> & {
61
+ alwaysRender?: boolean;
62
+ } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
63
+ declare const CommandItem: React.ForwardRefExoticComponent<Omit<{
64
+ children?: React.ReactNode;
65
+ } & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement> | "key"> & {
66
+ ref?: React.Ref<HTMLDivElement>;
67
+ } & {
68
+ asChild?: boolean;
69
+ }, keyof React.HTMLAttributes<HTMLDivElement> | "asChild" | "key">, "onSelect" | "disabled" | "value"> & {
70
+ disabled?: boolean;
71
+ onSelect?: (value: string) => void;
72
+ value?: string;
73
+ keywords?: string[];
74
+ forceMount?: boolean;
75
+ } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
76
+ declare const CommandShortcut: {
77
+ ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
78
+ displayName: string;
79
+ };
80
+ export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator, };
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ export default function SearchableSelect({ value, onSearch, onValueChange, disabled, placeholder, options, loading, }: {
3
+ value: string;
4
+ onValueChange: (value: string) => void;
5
+ onSearch: (search: string) => void;
6
+ disabled: boolean;
7
+ placeholder: string;
8
+ options: {
9
+ value: string;
10
+ label: string;
11
+ }[];
12
+ loading?: boolean;
13
+ }): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ declare function App(): import("react").JSX.Element;
2
+ export default App;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
3
+ declare const Dialog: React.FC<DialogPrimitive.DialogProps>;
4
+ declare const DialogTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
+ declare const DialogPortal: React.FC<DialogPrimitive.DialogPortalProps>;
6
+ declare const DialogClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
7
+ declare const DialogOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
8
+ declare const DialogContent: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
+ declare const DialogHeader: {
10
+ ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
11
+ displayName: string;
12
+ };
13
+ declare const DialogFooter: {
14
+ ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
15
+ displayName: string;
16
+ };
17
+ declare const DialogTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
18
+ declare const DialogDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
19
+ export { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, };
@@ -0,0 +1 @@
1
+ import './index.css';
@@ -0,0 +1,3 @@
1
+ import { ReportHandler } from 'web-vitals';
2
+ declare const reportWebVitals: (onPerfEntry?: ReportHandler) => void;
3
+ export default reportWebVitals;
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';