@dreamtree-org/twreact-ui 1.1.67 → 1.1.69

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 (3) hide show
  1. package/README.md +43 -17
  2. package/doc/README.md +1 -1
  3. package/package.json +6 -2
package/README.md CHANGED
@@ -266,7 +266,8 @@ const formFields = [
266
266
  ```
267
267
 
268
268
  #### Table
269
- Feature-rich data table with sorting, filtering, and pagination.
269
+ Feature-rich data table with sorting, filtering, pagination, conditional row
270
+ actions, and expandable row details.
270
271
 
271
272
  **Props:**
272
273
  - `data`: Array<object>
@@ -275,18 +276,33 @@ Feature-rich data table with sorting, filtering, and pagination.
275
276
  - `filterable`: boolean
276
277
  - `selectable`: boolean
277
278
  - `pagination`: boolean
278
- - `pageSize`: number (default: 10)
279
+ - `pageSize`: number (default: 25)
279
280
  - `onSort`: (key: string, direction: 'asc' | 'desc') => void
280
281
  - `onFilter`: (filters: object) => void
281
- - `onSelectionChange`: (selectedRows: Set<any>) => void
282
- - `onRowClick`: (row: object) => void
283
- - `hasDetails`: boolean
282
+ - `onSelectionChange`: (selectedRows: object[]) => void
283
+ - `onRowClick`: (row: object, index: number) => void
284
+ - `onPageChange`: (page: number) => void
285
+ - `hasDetails`: boolean | ((row, index) => boolean)
284
286
  - `DetailsComponent`: ReactComponent
285
- - `withAction`: boolean
286
- - `onAction`: (action: string, row: object) => void
287
- - `actions`: Array<Action>
287
+ - `withAction`: boolean (default: true)
288
+ - `onAction`: ({ action, row }) => void
289
+ - `actions`: Array<Action> | ((row, index) => Array<Action>)
290
+ - `replaceDefaultActions`: boolean (default: false)
288
291
  - `showSerial`: boolean (default: true)
289
292
 
293
+ An `Action` is `{ name, label, icon, render?, onClick?, hidden?, disabled?,
294
+ inline? }`. `label`, `icon`, `hidden` and `disabled` each accept a value **or** a
295
+ `(row, index) => value` producer, so actions can vary per row. `inline: true`
296
+ renders the action as an icon button in the row itself instead of inside the
297
+ kebab menu; when no menu actions remain for a row, the kebab is not rendered.
298
+
299
+ Supplied `actions` are **merged onto the built-in Edit/Delete/View set by
300
+ `name`** — `{ name: 'edit', onClick }` patches just that handler and keeps the
301
+ default label and icon, and `{ name: 'delete', hidden: true }` removes a default.
302
+ Entries with an unrecognised `name` are appended. Pass `replaceDefaultActions` to
303
+ skip merging and use only your own set. See [`doc/Table.md`](doc/Table.md) for
304
+ the full contract.
305
+
290
306
  ```jsx
291
307
  const columns = [
292
308
  { key: 'name', label: 'Name', sortable: true },
@@ -429,7 +445,7 @@ Notification messages with different types and positions.
429
445
  - `position`: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center'
430
446
 
431
447
  ```jsx
432
- import { useToast, ToastContainer } from 'dreamtree-ui';
448
+ import { useToast, ToastContainer } from '@dreamtree-org/twreact-ui';
433
449
 
434
450
  function App() {
435
451
  const { toast, toasts, removeToast } = useToast();
@@ -580,7 +596,7 @@ module.exports = {
580
596
  Enable dark mode with the built-in theme provider:
581
597
 
582
598
  ```jsx
583
- import { ThemeProvider } from 'dreamtree-ui';
599
+ import { ThemeProvider } from '@dreamtree-org/twreact-ui';
584
600
 
585
601
  function App() {
586
602
  return (
@@ -596,7 +612,7 @@ function App() {
596
612
  ### Complete Form Example
597
613
 
598
614
  ```jsx
599
- import { Form, Button, Card } from 'dreamtree-ui';
615
+ import { Form, Button, Card } from '@dreamtree-org/twreact-ui';
600
616
 
601
617
  const formFields = [
602
618
  {
@@ -650,7 +666,7 @@ function ContactForm() {
650
666
  ### Data Table with Actions
651
667
 
652
668
  ```jsx
653
- import { Table, Button, Badge } from 'dreamtree-ui';
669
+ import { Table } from '@dreamtree-org/twreact-ui';
654
670
 
655
671
  const columns = [
656
672
  { key: 'name', label: 'Name', sortable: true },
@@ -673,15 +689,25 @@ const data = [
673
689
  }
674
690
  ];
675
691
 
692
+ // Entries are merged onto the built-in Edit/Delete/View set by `name`.
676
693
  const actions = [
694
+ // patches the built-in `edit` — keeps its default label and icon
695
+ {
696
+ name: 'edit',
697
+ onClick: ({ action, row }) => console.log('Edit', row)
698
+ },
699
+ // rendered as an icon button in the row, and only for Active users
677
700
  {
678
- label: 'Edit',
679
- onClick: (row) => console.log('Edit', row)
701
+ name: 'deactivate',
702
+ label: 'Deactivate',
703
+ inline: true,
704
+ hidden: (row) => row.status !== 'Active',
705
+ onClick: ({ action, row }) => console.log('Deactivate', row)
680
706
  },
707
+ // drop a built-in you don't want
681
708
  {
682
- label: 'Delete',
683
- onClick: (row) => console.log('Delete', row),
684
- variant: 'destructive'
709
+ name: 'delete',
710
+ hidden: true
685
711
  }
686
712
  ];
687
713
 
package/doc/README.md CHANGED
@@ -72,7 +72,7 @@ function App() {
72
72
  | [Input](Input.md) | Core | Text input with label, error, clear, password toggle | [Input.md](Input.md) |
73
73
  | [Button](Button.md) | Core | Button with variants, sizes, loading, icons | [Button.md](Button.md) |
74
74
  | [Select](Select.md) | Core | Single/multi select, searchable, grouped, creatable | [Select.md](Select.md) |
75
- | [Table](Table.md) | Core | Data table with sort, filter, pagination, selection | [Table.md](Table.md) |
75
+ | [Table](Table.md) | Core | Data table with sort, filter, pagination, selection, conditional/inline row actions, expandable details | [Table.md](Table.md) |
76
76
  | [Form](Form.md) | Core | Form wrapper with react-hook-form integration | [Form.md](Form.md) |
77
77
  | [Accordion](Accordion.md) | Core | Expandable/collapsible content panels | [Accordion.md](Accordion.md) |
78
78
  | [Checkbox](Checkbox.md) | Core | Checkbox with label, sizes, indeterminate | [Checkbox.md](Checkbox.md) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamtree-org/twreact-ui",
3
- "version": "1.1.67",
3
+ "version": "1.1.69",
4
4
  "description": "A comprehensive React + Tailwind components library for building modern web apps",
5
5
  "author": {
6
6
  "name": "Partha Preetham Krishna",
@@ -54,6 +54,10 @@
54
54
  "init:smoke": "node bin/smoke.mjs",
55
55
  "readme:check": "node scripts/readme-sync-check.mjs",
56
56
  "adoption:report": "node scripts/adoption-report.mjs",
57
+ "graph": "node scripts/graphify.mjs .",
58
+ "graph:update": "node scripts/graphify.mjs . --update --no-viz",
59
+ "graph:check": "node scripts/graphify.mjs check",
60
+ "graph:context": "node scripts/graphify.mjs context",
57
61
  "version:patch": "npm version patch && git push && git push --tags",
58
62
  "version:minor": "npm version minor && git push && git push --tags",
59
63
  "version:major": "npm version major && git push && git push --tags",
@@ -86,7 +90,7 @@
86
90
  "homepage": "https://github.com/preethamkrishnadev/dreamtree-ui#readme",
87
91
  "license": "MIT",
88
92
  "engines": {
89
- "node": ">=18.0.0"
93
+ "node": ">=20.0.0"
90
94
  },
91
95
  "peerDependencies": {
92
96
  "react": "^18.3.1",