react-tailwind-table 1.1.1 → 1.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.
- package/README.md +65 -2
- package/dist/index.css +420 -326
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/src/table-sub-components.d.ts +5 -2
- package/dist/src/table-types.d.ts +26 -2
- package/package.json +7 -9
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ A few features that comes with this table include
|
|
|
16
16
|
- 5) Bulk Item Action
|
|
17
17
|
- 6) Customizable table data display
|
|
18
18
|
- 7) Full custom styling
|
|
19
|
+
- 8) Translatable texts and RTL support
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
> Contents
|
|
@@ -45,6 +46,8 @@ A few features that comes with this table include
|
|
|
45
46
|
- [Striped Table](#striped-table)
|
|
46
47
|
- [Hover Indicator](#hover-indicator)
|
|
47
48
|
- [Table With and Without Borders](#table-with-and-without-borders)
|
|
49
|
+
- [Translation](#translation)
|
|
50
|
+
- [RTL Support](#rtl-support)
|
|
48
51
|
- [Customization and Custom Styling](#customization-and-custom-styling)
|
|
49
52
|
- [Using In Your Component](#using-in-your-component)
|
|
50
53
|
- [Looks and Feel](#looks-and-feel)
|
|
@@ -98,7 +101,7 @@ interface Iprop {
|
|
|
98
101
|
columns: Icolumn[],
|
|
99
102
|
per_page?: number,
|
|
100
103
|
table_header?: string,
|
|
101
|
-
no_content_text?:
|
|
104
|
+
no_content_text?: React.ReactNode,
|
|
102
105
|
debounce_search?: number,
|
|
103
106
|
show_search?: boolean,
|
|
104
107
|
should_export?: boolean,
|
|
@@ -115,6 +118,11 @@ interface Iprop {
|
|
|
115
118
|
export_modify?: (row: Irow, col: Icolumn, display_value: string) => string,
|
|
116
119
|
on_bulk_action?: (selected_option: string, selected: Irow[]) => void,
|
|
117
120
|
|
|
121
|
+
search_placeholder?: string,
|
|
122
|
+
bulk_select_placeholder?: string,
|
|
123
|
+
pagination_info?: (info: { from: number, to: number, total: number }) => React.ReactNode,
|
|
124
|
+
dir?: 'ltr' | 'rtl' | 'auto',
|
|
125
|
+
|
|
118
126
|
//This will be discussed properly in the course of the documentation
|
|
119
127
|
styling ?: ItableStyle
|
|
120
128
|
}
|
|
@@ -298,7 +306,13 @@ type searchCallback = (search_word: string, result?: Irow[] | []) => void
|
|
|
298
306
|
|
|
299
307
|
### No Content Message
|
|
300
308
|
|
|
301
|
-
When there is no data to display (rows props is empty), the `No Data Availaible` text is shown. The `no_content_text`
|
|
309
|
+
When there is no data to display (rows props is empty), the `No Data Availaible` text is shown. The `no_content_text` prop controls what is shown. It accepts anything React can render: a string, a number, or a React element such as a component:
|
|
310
|
+
|
|
311
|
+
```jsx
|
|
312
|
+
<Table columns={columns} rows={[]} no_content_text="Nothing to see here" />
|
|
313
|
+
|
|
314
|
+
<Table columns={columns} rows={[]} no_content_text={<EmptyState />} />
|
|
315
|
+
```
|
|
302
316
|
|
|
303
317
|
|
|
304
318
|
### Hide Search
|
|
@@ -366,6 +380,55 @@ A `bg-gray-50` color can be applied on a row when the mouse hovered over it. Con
|
|
|
366
380
|
The borders of a the table can be controlled with the `bordered` prop.
|
|
367
381
|
|
|
368
382
|
|
|
383
|
+
### Translation
|
|
384
|
+
|
|
385
|
+
Every text shown by the table can be changed, so the table can be used in any language.
|
|
386
|
+
|
|
387
|
+
| Prop | Default | Where it shows |
|
|
388
|
+
| --- | --- | --- |
|
|
389
|
+
| `search_placeholder` | `SEARCH` | Placeholder of the search input |
|
|
390
|
+
| `bulk_select_placeholder` | `Select ...` | First option of the bulk action dropdown |
|
|
391
|
+
| `bulk_select_button_text` | `Apply` | Bulk action button |
|
|
392
|
+
| `export_text` | `Export` | CSV export button |
|
|
393
|
+
| `no_content_text` | `No Data Availaible` | Shown when there are no rows |
|
|
394
|
+
| `pagination_info` | `Showing {from} to {to} of {total} entries` | Footer statistics |
|
|
395
|
+
|
|
396
|
+
`pagination_info` is a function, because word order differs between languages. It receives the numbers of the current page and returns what should be displayed (a string or any React node):
|
|
397
|
+
|
|
398
|
+
```jsx
|
|
399
|
+
<Table
|
|
400
|
+
columns={columns}
|
|
401
|
+
rows={rows}
|
|
402
|
+
search_placeholder="Rechercher"
|
|
403
|
+
bulk_select_placeholder="Choisir ..."
|
|
404
|
+
bulk_select_button_text="Appliquer"
|
|
405
|
+
export_text="Exporter"
|
|
406
|
+
no_content_text="Aucune donnée"
|
|
407
|
+
pagination_info={({ from, to, total }) => <>Affichage de <b>{from}</b> à <b>{to}</b> sur <b>{total}</b> entrées</>}
|
|
408
|
+
/>
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
When `pagination_info` is used, the `styling.footer.statistics.bold_numbers` classes are not applied, since you control the markup.
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
### RTL Support
|
|
415
|
+
|
|
416
|
+
The table supports right-to-left languages such as Arabic and Hebrew. The layout (columns, padding, search icon, pagination arrows, etc.) follows the text direction:
|
|
417
|
+
|
|
418
|
+
- If your page already sets the direction, e.g. `<html dir="rtl">`, the table follows it automatically.
|
|
419
|
+
- To set the direction of a single table, use the `dir` prop: `'ltr'`, `'rtl'` or `'auto'`.
|
|
420
|
+
|
|
421
|
+
```jsx
|
|
422
|
+
<Table
|
|
423
|
+
dir="rtl"
|
|
424
|
+
columns={columns}
|
|
425
|
+
rows={rows}
|
|
426
|
+
search_placeholder="חיפוש"
|
|
427
|
+
pagination_info={({ from, to, total }) => `מציג ${from} עד ${to} מתוך ${total} רשומות`}
|
|
428
|
+
/>
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
|
|
369
432
|
|
|
370
433
|
## Customization and Custom Styling
|
|
371
434
|
|