@sito/dashboard 0.0.46 → 0.0.48

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Sito
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Sito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,270 +1,270 @@
1
- # @sito/dashboard
2
-
3
- A React library for building customizable and responsive dashboards with ease.
4
-
5
- ## Features
6
-
7
- - **Table Component**: A powerful table component with support for sorting, pagination, and customizable columns.
8
- - **Translation Support**: Built-in translation support using a `TranslationProvider`.
9
- - **Customizable**: Easily style and configure components to fit your needs.
10
- - **Lightweight**: Optimized for performance and usability.
11
-
12
- ## Installation
13
-
14
- To install the library, use npm or yarn:
15
-
16
- ```bash
17
- # Using npm
18
- npm install @sito/dashboard
19
-
20
- # Using yarn
21
- yarn add @sito/dashboard
22
- ```
23
-
24
- ## Table
25
-
26
- Here’s how you can use the Table component in your project:
27
-
28
- ```bash
29
- import React from "react";
30
- import { Table } from "sito-dashboard";
31
-
32
- const App = () => {
33
- const rows = [
34
- { id: 1, name: "John Doe", age: 30 },
35
- { id: 2, name: "Jane Smith", age: 25 },
36
- ];
37
-
38
- const columns = [
39
- { key: "name", label: "Name" },
40
- { key: "age", label: "Age" },
41
- ];
42
-
43
- return (
44
- <Table
45
- title="User Table"
46
- data={rows}
47
- columns={columns}
48
- />
49
- );
50
- };
51
-
52
- export default App;
53
- ```
54
-
55
- ## Translation for its components
56
-
57
- Wrap your application with the TranslationProvider to enable translations:
58
-
59
- ```bash
60
- import React from "react";
61
- import { TranslationProvider } from "@sito/dashboard";
62
-
63
- const translations = {
64
- en: { hello: "Hello" },
65
- es: { hello: "Hola" },
66
- };
67
-
68
- const App = () => {
69
- const t = (key) => translations["en"][key]; // Example translation function
70
-
71
- return (
72
- <TranslationProvider t={t}>
73
- <h1>{t("hello")}</h1>
74
- </TranslationProvider>
75
- );
76
- };
77
-
78
- export default App;
79
- ```
80
-
81
- ## Components
82
-
83
- ### Table
84
-
85
- The Table component is a flexible and feature-rich table for displaying data.
86
-
87
- #### Props
88
- | Propiedad | Tipo | Valor por defecto | Descripción |
89
- |-----------------------|--------------|-------------------------|---------------------------------------------------------------------|
90
- | `title` | `string` | `""` | El título de la tabla. |
91
- | `data` | `array` | — | Los datos a mostrar en la tabla. |
92
- | `columns` | `array` | `[]` | Definiciones de columnas, incluyendo claves (`key`) y etiquetas. |
93
- | `isLoading` | `boolean` | `false` | Indica si la tabla está en estado de carga. |
94
- | `actions` | `Action[]` | — | Función para renderizar acciones por fila. |
95
- | `className` | `string` | `""` | Clase personalizada para el contenedor de la tabla. |
96
- | `contentClassName` | `string` | `""` | Clase personalizada para el contenido de la tabla. |
97
- | `softDeleteProperty` | `string` | `"deleted"` | Propiedad usada para lógica de borrado suave. |
98
- | `toolbar` | `ReactNode` | `<></>` | Componente personalizado para la barra de herramientas. |
99
- | `onSort` | `function` | — | Callback que se llama cuando se cambia el orden de la tabla. |
100
-
101
-
102
- ### TranslationProvider
103
-
104
- Provides translation support for your application.
105
-
106
- #### Props
107
- - `t` (function): A translation function that takes a key and returns the translated string.
108
-
109
- ### Examples
110
-
111
- #### Columns definition
112
-
113
- ```
114
- key: string;
115
- label: string;
116
- sortable?: boolean;
117
- sortOptions: {
118
- icons: {
119
- className: string;
120
- asc: string;
121
- desc: string;
122
- };
123
- };
124
- className?: string;
125
- display?: "visible" | "none";
126
- pos?: number;
127
- renderBody?: (value: any, row: any) => ReactNode;
128
- renderHead?: () => void;
129
- filterOptions?: ColumnFilterOptions;
130
- ```
131
-
132
- ColumnFilterOptions
133
-
134
- ```
135
- {
136
- type: FilterTypes;
137
- defaultValue: any;
138
- label?: string;
139
- }
140
- ```
141
-
142
- FilterTypes enum
143
-
144
- ```
145
- text,
146
- number,
147
- select,
148
- autocomplete,
149
- date,
150
- check,
151
- ```
152
-
153
- ```
154
- import { Table } from "@sito/dashboard";
155
-
156
- const columns = [
157
- {
158
- key: "tagIds",
159
- label: t("_entities:news.tags.label"),
160
- filterOptions: {
161
- type: FilterTypes.autocomplete,
162
- options: tagsList,
163
- defaultValue: [],
164
- },
165
- sortable: false,
166
- renderBody: (_, news) =>
167
- (
168
- <div className="flex flex-wrap gap-3">
169
- {news.tags?.map(({ name, id }) => (
170
- <Chip key={id} label={name} spanClassName="text-xs" />
171
- ))}
172
- </div>
173
- ) ?? " - ",
174
- },
175
- ]
176
-
177
- <Table data={...} columns={columns} />
178
- ```
179
-
180
- #### Actions definition
181
-
182
- ```
183
- {
184
- id: string;
185
- onClick: (entity: object) => void;
186
- icon: any;
187
- tooltip: string;
188
- hidden: (entity: object) => boolean;
189
- }
190
- ```
191
-
192
- ```
193
- import { Table } from "@sito/dashboard";
194
-
195
- const addAction = {
196
- id: "add",
197
- hidden: false,
198
- onClick: async () => {
199
- // do some stuff here
200
- },
201
- icon: (
202
- <FontAwesomeIcon
203
- icon={isLoading ? faSpinner : faAdd}
204
- className={`text-success ${isLoading ? "rotate" : ""}`}
205
- />
206
- ),
207
- tooltip: t("_accessibility:buttons.add"),
208
- }
209
-
210
- <Table data={...} columns={...} actions={[addAction]} />
211
- ```
212
-
213
- #### Your custom toolbar
214
-
215
- ```
216
- import { Table } from "@sito/dashboard";
217
-
218
- const Toolbar = () => {
219
- return <div>
220
- <h1>My custom toolbar</h1>
221
- </div>
222
- }
223
-
224
- <Table data={...} columns={...} toolbar={<Toolbar />} />
225
- ```
226
-
227
- ## Development
228
-
229
- Running Locally
230
-
231
- To run the project locally:
232
-
233
- 1. Clone the repository:
234
-
235
- ```bash
236
- git clone https://github.com/your-repo/sito-dashboard.git
237
-
238
- cd sito-dashboard
239
- ```
240
-
241
- 2. Install dependencies:
242
-
243
- ```bash
244
- npm install
245
- ```
246
-
247
- 3. Start the development server
248
-
249
- ```bash
250
- npm start
251
- ```
252
-
253
- Building the Library
254
-
255
- To build the library for production
256
-
257
- ```bash
258
- npm run build
259
- ```
260
-
261
- ## Contributing
262
-
263
- Contributions are welcome! Please follow these steps:
264
- 1. Fork the repository.
265
- 2. Create a new branch for your feature or bugfix.
266
- 3. Submit a pull request with a detailed description of your changes.
267
-
268
- ## License
269
-
1
+ # @sito/dashboard
2
+
3
+ A React library for building customizable and responsive dashboards with ease.
4
+
5
+ ## Features
6
+
7
+ - **Table Component**: A powerful table component with support for sorting, pagination, and customizable columns.
8
+ - **Translation Support**: Built-in translation support using a `TranslationProvider`.
9
+ - **Customizable**: Easily style and configure components to fit your needs.
10
+ - **Lightweight**: Optimized for performance and usability.
11
+
12
+ ## Installation
13
+
14
+ To install the library, use npm or yarn:
15
+
16
+ ```bash
17
+ # Using npm
18
+ npm install @sito/dashboard
19
+
20
+ # Using yarn
21
+ yarn add @sito/dashboard
22
+ ```
23
+
24
+ ## Table
25
+
26
+ Here’s how you can use the Table component in your project:
27
+
28
+ ```bash
29
+ import React from "react";
30
+ import { Table } from "sito-dashboard";
31
+
32
+ const App = () => {
33
+ const rows = [
34
+ { id: 1, name: "John Doe", age: 30 },
35
+ { id: 2, name: "Jane Smith", age: 25 },
36
+ ];
37
+
38
+ const columns = [
39
+ { key: "name", label: "Name" },
40
+ { key: "age", label: "Age" },
41
+ ];
42
+
43
+ return (
44
+ <Table
45
+ title="User Table"
46
+ data={rows}
47
+ columns={columns}
48
+ />
49
+ );
50
+ };
51
+
52
+ export default App;
53
+ ```
54
+
55
+ ## Translation for its components
56
+
57
+ Wrap your application with the TranslationProvider to enable translations:
58
+
59
+ ```bash
60
+ import React from "react";
61
+ import { TranslationProvider } from "@sito/dashboard";
62
+
63
+ const translations = {
64
+ en: { hello: "Hello" },
65
+ es: { hello: "Hola" },
66
+ };
67
+
68
+ const App = () => {
69
+ const t = (key) => translations["en"][key]; // Example translation function
70
+
71
+ return (
72
+ <TranslationProvider t={t}>
73
+ <h1>{t("hello")}</h1>
74
+ </TranslationProvider>
75
+ );
76
+ };
77
+
78
+ export default App;
79
+ ```
80
+
81
+ ## Components
82
+
83
+ ### Table
84
+
85
+ The Table component is a flexible and feature-rich table for displaying data.
86
+
87
+ #### Props
88
+ | Propiedad | Tipo | Valor por defecto | Descripción |
89
+ |-----------------------|--------------|-------------------------|---------------------------------------------------------------------|
90
+ | `title` | `string` | `""` | El título de la tabla. |
91
+ | `data` | `array` | — | Los datos a mostrar en la tabla. |
92
+ | `columns` | `array` | `[]` | Definiciones de columnas, incluyendo claves (`key`) y etiquetas. |
93
+ | `isLoading` | `boolean` | `false` | Indica si la tabla está en estado de carga. |
94
+ | `actions` | `Action[]` | — | Función para renderizar acciones por fila. |
95
+ | `className` | `string` | `""` | Clase personalizada para el contenedor de la tabla. |
96
+ | `contentClassName` | `string` | `""` | Clase personalizada para el contenido de la tabla. |
97
+ | `softDeleteProperty` | `string` | `"deleted"` | Propiedad usada para lógica de borrado suave. |
98
+ | `toolbar` | `ReactNode` | `<></>` | Componente personalizado para la barra de herramientas. |
99
+ | `onSort` | `function` | — | Callback que se llama cuando se cambia el orden de la tabla. |
100
+
101
+
102
+ ### TranslationProvider
103
+
104
+ Provides translation support for your application.
105
+
106
+ #### Props
107
+ - `t` (function): A translation function that takes a key and returns the translated string.
108
+
109
+ ### Examples
110
+
111
+ #### Columns definition
112
+
113
+ ```
114
+ key: string;
115
+ label: string;
116
+ sortable?: boolean;
117
+ sortOptions: {
118
+ icons: {
119
+ className: string;
120
+ asc: string;
121
+ desc: string;
122
+ };
123
+ };
124
+ className?: string;
125
+ display?: "visible" | "none";
126
+ pos?: number;
127
+ renderBody?: (value: any, row: any) => ReactNode;
128
+ renderHead?: () => void;
129
+ filterOptions?: ColumnFilterOptions;
130
+ ```
131
+
132
+ ColumnFilterOptions
133
+
134
+ ```
135
+ {
136
+ type: FilterTypes;
137
+ defaultValue: any;
138
+ label?: string;
139
+ }
140
+ ```
141
+
142
+ FilterTypes enum
143
+
144
+ ```
145
+ text,
146
+ number,
147
+ select,
148
+ autocomplete,
149
+ date,
150
+ check,
151
+ ```
152
+
153
+ ```
154
+ import { Table } from "@sito/dashboard";
155
+
156
+ const columns = [
157
+ {
158
+ key: "tagIds",
159
+ label: t("_entities:news.tags.label"),
160
+ filterOptions: {
161
+ type: FilterTypes.autocomplete,
162
+ options: tagsList,
163
+ defaultValue: [],
164
+ },
165
+ sortable: false,
166
+ renderBody: (_, news) =>
167
+ (
168
+ <div className="flex flex-wrap gap-3">
169
+ {news.tags?.map(({ name, id }) => (
170
+ <Chip key={id} label={name} spanClassName="text-xs" />
171
+ ))}
172
+ </div>
173
+ ) ?? " - ",
174
+ },
175
+ ]
176
+
177
+ <Table data={...} columns={columns} />
178
+ ```
179
+
180
+ #### Actions definition
181
+
182
+ ```
183
+ {
184
+ id: string;
185
+ onClick: (entity: object) => void;
186
+ icon: any;
187
+ tooltip: string;
188
+ hidden: (entity: object) => boolean;
189
+ }
190
+ ```
191
+
192
+ ```
193
+ import { Table } from "@sito/dashboard";
194
+
195
+ const addAction = {
196
+ id: "add",
197
+ hidden: false,
198
+ onClick: async () => {
199
+ // do some stuff here
200
+ },
201
+ icon: (
202
+ <FontAwesomeIcon
203
+ icon={isLoading ? faSpinner : faAdd}
204
+ className={`text-success ${isLoading ? "rotate" : ""}`}
205
+ />
206
+ ),
207
+ tooltip: t("_accessibility:buttons.add"),
208
+ }
209
+
210
+ <Table data={...} columns={...} actions={[addAction]} />
211
+ ```
212
+
213
+ #### Your custom toolbar
214
+
215
+ ```
216
+ import { Table } from "@sito/dashboard";
217
+
218
+ const Toolbar = () => {
219
+ return <div>
220
+ <h1>My custom toolbar</h1>
221
+ </div>
222
+ }
223
+
224
+ <Table data={...} columns={...} toolbar={<Toolbar />} />
225
+ ```
226
+
227
+ ## Development
228
+
229
+ Running Locally
230
+
231
+ To run the project locally:
232
+
233
+ 1. Clone the repository:
234
+
235
+ ```bash
236
+ git clone https://github.com/your-repo/sito-dashboard.git
237
+
238
+ cd sito-dashboard
239
+ ```
240
+
241
+ 2. Install dependencies:
242
+
243
+ ```bash
244
+ npm install
245
+ ```
246
+
247
+ 3. Start the development server
248
+
249
+ ```bash
250
+ npm start
251
+ ```
252
+
253
+ Building the Library
254
+
255
+ To build the library for production
256
+
257
+ ```bash
258
+ npm run build
259
+ ```
260
+
261
+ ## Contributing
262
+
263
+ Contributions are welcome! Please follow these steps:
264
+ 1. Fork the repository.
265
+ 2. Create a new branch for your feature or bugfix.
266
+ 3. Submit a pull request with a detailed description of your changes.
267
+
268
+ ## License
269
+
270
270
  This project is licensed under the MIT License.
@@ -0,0 +1,2 @@
1
+ import { FileInputPropsType } from './types';
2
+ export declare const FileInput: import('react').ForwardRefExoticComponent<Omit<FileInputPropsType, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,2 @@
1
+ export * from './FileInput';
2
+ export * from './types';
@@ -0,0 +1,8 @@
1
+ import { BaseInputPropsType } from 'main';
2
+ import { HTMLProps, ReactNode } from 'react';
3
+ export interface FileInputPropsType extends Omit<HTMLProps<HTMLInputElement>, "value" | "label">, BaseInputPropsType {
4
+ label: string;
5
+ iconClassName?: string;
6
+ multiple?: boolean;
7
+ children?: ReactNode;
8
+ }
@@ -0,0 +1 @@
1
+ export declare function truncateFileName(name: string, maxLength?: number): string;
@@ -2,5 +2,6 @@ export * from './SelectInput';
2
2
  export * from './TextInput';
3
3
  export * from './CheckInput';
4
4
  export * from './AutocompleteInput';
5
+ export * from './FileInput';
5
6
  export * from './utils';
6
7
  export * from './types';
@@ -0,0 +1,2 @@
1
+ import { IconProps } from './types';
2
+ export declare function File(props: IconProps): import("react/jsx-runtime").JSX.Element;
@@ -4,4 +4,5 @@ export * from './ChevronRight';
4
4
  export * from './ChevronLeft';
5
5
  export * from './Filters';
6
6
  export * from './Close';
7
+ export * from './File';
7
8
  export * from './types';
@@ -1 +1,3 @@
1
1
  export * from './ActiveFilters';
2
+ export * from './ArrayChip';
3
+ export * from './RangeChip';
@@ -1,7 +1,7 @@
1
1
  export * from './Columns';
2
2
  export * from './Empty';
3
3
  export * from './Footer';
4
- export * from './Filters/FilterDropdown';
4
+ export * from './Filters';
5
5
  export * from './TableHeader';
6
6
  export * from './Rows';
7
7
  export * from './types';
@@ -3,7 +3,7 @@ import { Action } from '../types';
3
3
  import { BaseDto, FilterTypes, SortOrder } from '../../../lib';
4
4
  import { Option } from '../../Form/';
5
5
  export type ColumnType<TRow extends BaseDto> = {
6
- key: keyof TRow;
6
+ key: string;
7
7
  label?: string;
8
8
  /** if the column can be sorted */
9
9
  sortable?: boolean;