@roy-ui/ui 0.0.4 → 0.0.6

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
@@ -1,6 +1,7 @@
1
1
  # @roy-ui/ui
2
2
 
3
- > Free, animated React components built with TypeScript. Zero config, RSC-safe, sub-12 KB.
3
+ > A modern **React component library** for **Next.js 15**, **Vite**, **Remix**, **TanStack Start**, and any **React 18+** bundler.
4
+ > Ships a fully-featured **React data table** with search, **date range picker**, **analog & digital time picker**, **pagination**, **column reorder / resize / hide**, **CSV / JSON export & import**, **per-zone typography**, plus animated micro-interaction primitives — **TypeScript-first**, **RSC-safe**, **tree-shakable ESM**, **zero config**.
4
5
 
5
6
  [![npm version](https://img.shields.io/npm/v/@roy-ui/ui?logo=npm&label=npm&color=cb3837)](https://www.npmjs.com/package/@roy-ui/ui)
6
7
  [![npm downloads](https://img.shields.io/npm/dm/@roy-ui/ui?logo=npm&label=downloads&color=cb3837)](https://www.npmjs.com/package/@roy-ui/ui)
@@ -8,26 +9,31 @@
8
9
  [![types](https://img.shields.io/npm/types/@roy-ui/ui?color=3178C6&logo=typescript&logoColor=white)](https://www.npmjs.com/package/@roy-ui/ui)
9
10
  [![license](https://img.shields.io/npm/l/@roy-ui/ui?color=22c55e)](https://github.com/DibbayajyotiRoy/RoyUI/blob/main/LICENSE)
10
11
 
12
+ **[Open the live documentation →](https://royui.dev/components/data-table)**
13
+
11
14
  <a href="https://github.com/DibbayajyotiRoy/RoyUI/blob/main/apps/docs/lib/demo/linkedin2.mp4">
12
15
  <img
13
16
  src="https://raw.githubusercontent.com/DibbayajyotiRoy/RoyUI/main/apps/docs/lib/demo/demo.gif"
14
- alt="Roy UI components demo — gradient button, popover, text morph, made-by badge"
17
+ alt="Roy UI React component library demo — animated data table with search, date range picker, time picker, pagination, column reorder, CSV export, gradient button, popover, text morph"
15
18
  width="720" />
16
19
  </a>
17
20
 
18
- <sub>Click the GIF for the full-quality video.</sub>
19
-
20
21
  ---
21
22
 
22
- ## What is it?
23
+ ## Why @roy-ui/ui?
24
+
25
+ You're building a React dashboard, admin panel, internal tool, or product UI in **Next.js 15 App Router**, **Vite**, **Remix**, **Astro**, or **TanStack Start**. You want a **production-grade table component** with filtering, paginate, sort, drag-to-reorder columns, resize, hide, export — **without** wiring up TanStack Table, AG Grid, or React Table from scratch. You want **clean, animated micro-interaction components** — without installing Tailwind, configuring PostCSS, or pulling in Framer Motion. You want **TypeScript** and **React Server Component** support out of the box.
23
26
 
24
- `@roy-ui/ui` is an open-source React component library focused on animated, micro-interactive UI primitives — gradient buttons, popovers, text-morph effects, attribution badges — written in TypeScript, shipped as tree-shakable ESM, and fully compatible with React Server Components, Next.js 15, Vite, Remix, and any modern React 18+ runtime.
27
+ `@roy-ui/ui` is that library. One `npm install`. One import. Production-ready.
25
28
 
26
- - **Zero runtime config** install, import, render.
27
- - **Tree-shakable ESM** with first-class TypeScript types and source maps.
28
- - **Self-contained CSS** — no Tailwind plugin, no PostCSS, no theme provider.
29
- - **RSC-safe** — components are correctly marked `"use client"` inside the bundle.
30
- - **Tiny** — the whole library is under 12 KB minified + gzipped.
29
+ - **Drop-in React DataTable** with search, date range, time, pagination, reorder, resize, hide, CSV / JSON IO
30
+ - **Built-in custom date range picker** 2-month modal, hover-preview, presets, no `date-fns` required
31
+ - **Built-in custom time picker** — analog wristwatch *and* digital, AM / PM toggle, user-switchable
32
+ - **Animated primitives** — gradient button with loading spinner, popover, text morph, tree nav, floating "Made by" badge
33
+ - **Zero runtime config** — no Tailwind plugin, no theme provider, no design-token setup
34
+ - **TypeScript-first** — tree-shakable ESM with first-class `.d.ts` types and source maps
35
+ - **RSC-safe (React Server Components-safe)** — `"use client"` boundary inside the bundle; import directly from a Next.js App Router server component
36
+ - **Framework-agnostic** — Next.js, Vite, Remix, Astro (React island), TanStack Start, CRA, any ESM bundler
31
37
 
32
38
  ## Install
33
39
 
@@ -41,69 +47,297 @@ yarn add @roy-ui/ui
41
47
  bun add @roy-ui/ui
42
48
  ```
43
49
 
44
- Requires React 18 or newer.
50
+ **Peer dependency:** React 18 or newer (React 19 supported).
45
51
 
46
- ## Quick start
52
+ ## Quick start — React DataTable
47
53
 
48
54
  ```tsx
49
- import {
50
- GradientButton,
51
- Popover,
52
- TextMorph,
53
- MadeBy,
54
- } from '@roy-ui/ui';
55
+ 'use client';
56
+
57
+ import { useState } from 'react';
58
+ import { DataTable, type Column } from '@roy-ui/ui';
59
+
60
+ type Order = {
61
+ id: string;
62
+ customer: string;
63
+ total: number;
64
+ placedAt: Date;
65
+ status: 'paid' | 'pending' | 'refunded';
66
+ };
67
+
68
+ const columns: Column<Order>[] = [
69
+ { key: 'id', header: 'Order', accessor: (r) => r.id, isRowHeader: true },
70
+ { key: 'customer', header: 'Customer', accessor: (r) => r.customer },
71
+ { key: 'status', header: 'Status', accessor: (r) => r.status },
72
+ { key: 'placedAt', header: 'Placed', accessor: (r) => r.placedAt, type: 'date' },
73
+ {
74
+ key: 'time',
75
+ header: 'Time',
76
+ accessor: (r) => r.placedAt,
77
+ type: 'time',
78
+ },
79
+ {
80
+ key: 'total',
81
+ header: 'Total',
82
+ accessor: (r) => r.total,
83
+ type: 'number',
84
+ cell: (v) => `$${(v as number).toFixed(2)}`,
85
+ },
86
+ ];
87
+
88
+ export default function OrdersTable({ orders }: { orders: Order[] }) {
89
+ const [data, setData] = useState(orders);
55
90
 
56
- export default function Hero() {
57
91
  return (
58
- <main>
59
- <TextMorph value="Hello, world." />
60
-
61
- <GradientButton loading={false}>
62
- Get started
63
- </GradientButton>
64
-
65
- <Popover label="Help" title="Need a hand?" align="right" width="md">
66
- <p>Read the docs, ping the maintainer, or open an issue.</p>
67
- </Popover>
68
-
69
- <MadeBy
70
- name="Dibbayajyoti"
71
- href="https://github.com/DibbayajyotiRoy"
72
- position="bottom-right"
73
- />
74
- </main>
92
+ <DataTable<Order>
93
+ data={data}
94
+ columns={columns}
95
+ visibleRows={8}
96
+ search={{ enabled: true, placeholder: 'Search orders' }}
97
+ dateFilter={{ column: 'placedAt', monthsVisible: 2 }}
98
+ timeFilter={{ column: 'time', variant: 'analog', toleranceMinutes: 60 }}
99
+ pagination={{ pageSize: 25 }}
100
+ dataIO={{
101
+ export: { enabled: true, filename: 'orders' },
102
+ import: { enabled: true, onImport: setData },
103
+ }}
104
+ />
75
105
  );
76
106
  }
77
107
  ```
78
108
 
79
- Using the **Next.js App Router**? Import directly from a Server Component — the interactive bits inside `@roy-ui/ui` carry their own `"use client"` boundary.
109
+ > Using the **Next.js App Router**? Import directly from a Server Component — the interactive bits inside `@roy-ui/ui` carry their own `"use client"` boundary.
80
110
 
81
- ## Components
111
+ ## What's in the box
112
+
113
+ ### Display / Data
82
114
 
83
115
  | Component | What it does |
84
116
  | --- | --- |
85
- | **`GradientButton`** | Animated blue–cyan gradient button with a built-in spinner. Props: `loading`, `loadingLabel`, `fullWidth`. |
86
- | **`Popover`** | Accessible click-to-open popover with corner alignment (`left`/`right`) and width presets (`sm`/`md`/`lg`/number). |
87
- | **`TextMorph`** | Character-by-character text diff animation. Great for live counters, currency tickers, and status text. |
117
+ | **[`DataTable<T>`](https://royui.dev/components/data-table)** | Generic, fully-featured **React data table**. Search across columns, sort, paginate, **drag headers to reorder**, **drag the right edge to resize**, **Columns menu** to hide & restore, **CSV / JSON export & import**, **per-zone typography** for headers / row-headers / cells, optional `fitColumns` to disable horizontal scroll, optional `localStorage` persistence. |
118
+ | **`Table`** + parts | Standalone primitive `Table`, `TableHeader`, `TableBody`, `TableRow`, `TableHead`, `TableCell`. Scrollable rows (`visibleRows`, default 7), sticky header, density scale (compact / cozy / comfortable), inline `Spinner`. |
119
+ | **`TableSearch`** | Debounced search input, clear button, controlled & uncontrolled modes. |
120
+ | **`Pagination`** | Numbered pages with text Prev / Next, ellipsis, optional `Page X of Y` summary. |
121
+ | **`DateRangePicker`** | **Custom React date range picker** — 2 (or N) months side-by-side in a popover, hover-preview the range, preset sidebar (Today / Last 7d / Last 30d / This month / Last month), min / max bounds, zero `date-fns` dependency. |
122
+ | **`TimePicker`** | **Custom React time picker** with two variants — **analog clock face** (drag the hour & minute hands, AM / PM segmented pill) and **digital** (scroll-wheel or arrow keys per segment). User can switch between them. 12h or 24h cycle, configurable minute step. |
123
+ | **`Spinner`** | Inline animated SVG spinner. Used as the default loading state across the library. |
124
+ | **`TreeNav`** + `TreeNavItem` | Sidebar sub-nav with file-explorer-style L-shaped branch connectors. Router-agnostic via `asChild`, active state driven by `aria-current`. |
125
+ | **`TextMorph`** | Character-by-character text diff animation — great for live counters, currency tickers, status text. |
88
126
  | **`MadeBy`** | Floating "Made by ___" attribution badge with corner positioning. |
89
127
 
90
- ## Why use this?
128
+ ### Inputs / Overlay
129
+
130
+ | Component | What it does |
131
+ | --- | --- |
132
+ | **`GradientButton`** | Animated blue → cyan → blue gradient CTA with a built-in loading spinner. |
133
+ | **`Popover`** | Accessible click-to-open popover with corner alignment (`left` / `right`) and width presets. |
134
+
135
+ ## DataTable feature matrix
136
+
137
+ | Feature | Prop / API | Notes |
138
+ | --- | --- | --- |
139
+ | Search across all columns | `search={{ enabled: true }}` | Debounced; override matcher with `search.predicate` |
140
+ | Date range filter on a column | `dateFilter={{ column, monthsVisible }}` | 2-month modal by default; pass any N |
141
+ | Time-of-day filter on a column | `timeFilter={{ column, variant, toleranceMinutes }}` | `variant: 'analog' \| 'digital'`, both user-switchable |
142
+ | Click-to-sort | always on | Tri-state per column: asc → desc → off |
143
+ | Pagination | `pagination={{ pageSize }}` or `false` | Text Prev / Next + numbered pages |
144
+ | Column drag-to-reorder | `reorderable` (default `true`) | Native HTML5 DnD, drop indicator |
145
+ | Column resize | `resizable` (default `true`) | Drag right edge of header; double-click resets |
146
+ | Column hide / restore | `columnMenu` (default `true`) | "Columns" popover + hidden-count chip for instant restore |
147
+ | Pinned columns | `pinned: 'left' \| 'right'` per column | Excluded from reorder |
148
+ | CSV export | `dataIO.export` | Built-in RFC 4180 writer |
149
+ | JSON export | `dataIO.export` | Native `JSON.stringify` |
150
+ | CSV / JSON import | `dataIO.import` | File picker → parsed rows → `onImport` |
151
+ | Per-zone fonts | `headerFont`, `rowHeaderFont`, `cellFont` | Plus per-column `font` |
152
+ | Persist layout | `storageKey` | Order, sizes, hidden state in `localStorage` |
153
+ | Disable horizontal scroll | `fitColumns` | Columns auto-distribute; cells wrap |
154
+ | Loading state | `loading` | Dims body, overlays inline `Spinner` |
155
+ | Custom empty slot | `empty` | Any `ReactNode` |
156
+ | Generic over row type | `DataTable<T>` | Full TypeScript inference |
157
+
158
+ ## Custom date range picker — standalone
159
+
160
+ ```tsx
161
+ 'use client';
162
+
163
+ import { useState } from 'react';
164
+ import { DateRangePicker, type DateRange } from '@roy-ui/ui';
165
+
166
+ export function BookingPicker() {
167
+ const [range, setRange] = useState<DateRange>({ from: null, to: null });
168
+
169
+ return (
170
+ <DateRangePicker
171
+ value={range}
172
+ onChange={setRange}
173
+ monthsVisible={2}
174
+ weekStartsOn={1}
175
+ minDate={new Date()}
176
+ />
177
+ );
178
+ }
179
+ ```
180
+
181
+ ## Custom time picker — analog and digital
182
+
183
+ ```tsx
184
+ 'use client';
185
+
186
+ import { useState } from 'react';
187
+ import { TimePicker, type TimeValue } from '@roy-ui/ui';
188
+
189
+ export function ShiftStartPicker() {
190
+ const [time, setTime] = useState<TimeValue | null>(null);
191
+
192
+ return (
193
+ <TimePicker
194
+ value={time}
195
+ onChange={setTime}
196
+ variant="analog" // or "digital" — user can also switch from the panel
197
+ hourCycle={12} // or 24
198
+ minuteStep={5}
199
+ />
200
+ );
201
+ }
202
+ ```
203
+
204
+ ## Standalone table primitives
205
+
206
+ If `DataTable` is more than you need, the primitives ship on their own.
207
+
208
+ ```tsx
209
+ import {
210
+ Table,
211
+ TableHeader,
212
+ TableBody,
213
+ TableRow,
214
+ TableHead,
215
+ TableCell,
216
+ } from '@roy-ui/ui';
217
+
218
+ <Table visibleRows={5} stickyHeader>
219
+ <TableHeader>
220
+ <TableRow>
221
+ <TableHead>Order</TableHead>
222
+ <TableHead>Customer</TableHead>
223
+ <TableHead align="right">Total</TableHead>
224
+ </TableRow>
225
+ </TableHeader>
226
+ <TableBody>
227
+ {orders.map((o) => (
228
+ <TableRow key={o.id}>
229
+ <TableCell isRowHeader>{o.id}</TableCell>
230
+ <TableCell>{o.customer}</TableCell>
231
+ <TableCell align="right">${o.total.toFixed(2)}</TableCell>
232
+ </TableRow>
233
+ ))}
234
+ </TableBody>
235
+ </Table>
236
+ ```
237
+
238
+ ## React data table comparison — `@roy-ui/ui` vs TanStack Table vs AG Grid vs Material React Table
239
+
240
+ | | `@roy-ui/ui` (DataTable) | TanStack Table v8 | AG Grid Community | Material React Table |
241
+ | --- | --- | --- | --- | --- |
242
+ | Ships visual styles | Yes | No (headless) | Yes | Yes (Material UI required) |
243
+ | Built-in date range filter | Yes | No (build it) | Enterprise only | No |
244
+ | Built-in time picker filter | Yes (analog + digital) | No | No | No |
245
+ | Built-in CSV / JSON export | Yes | No | Yes | Partial |
246
+ | Drag-to-reorder columns | Yes (native, no deps) | Manual + DnD lib | Yes | Yes (Material UI) |
247
+ | Column resize | Yes | Manual | Yes | Yes |
248
+ | Column hide / show menu | Yes | Manual | Yes | Yes |
249
+ | Required dependency tree | React only | React only | `@ag-grid-community/*` | `@mui/*` + `@tanstack/*` |
250
+ | RSC-safe with Next.js App Router | Yes | Manual | Manual | Manual |
251
+ | TypeScript-first generic over row type `T` | Yes | Yes | Partial | Yes |
252
+ | License | MIT | MIT | MIT (community) | MIT |
253
+
254
+ **When to use each:**
255
+
256
+ - Need **maximum flexibility, no styles, you wire everything**? Use **TanStack Table v8**.
257
+ - Need **Excel-style spreadsheet** with pivot, master-detail, infinite scroll, **enterprise license**? Use **AG Grid**.
258
+ - Already deep in **Material UI**? Use **Material React Table**.
259
+ - Need a **clean, modern React data table** with **search + date range + time + paginate + reorder + resize + hide + CSV / JSON** working out of the box in a Next.js app, zero setup? Use **`@roy-ui/ui`**.
260
+
261
+ ## React UI library comparison — `@roy-ui/ui` vs shadcn/ui vs Aceternity vs MUI vs Radix
262
+
263
+ | | `@roy-ui/ui` | shadcn/ui | Aceternity / Magic UI | Radix / Headless UI | MUI |
264
+ | --- | --- | --- | --- | --- | --- |
265
+ | Single `npm install` (no CLI, no copy) | Yes | No (copy-paste CLI) | No (copy-paste) | Yes | Yes |
266
+ | Ships visual styles | Yes | Yes | Yes | No | Yes |
267
+ | RSC-safe out of the box | Yes | Yes | Manual | Manual | Manual |
268
+ | Tailwind required | No | Yes | Yes | No | No |
269
+ | Framer Motion required | No | No | Yes | No | No |
270
+ | Animation built in | Yes | Sometimes | Yes | No | Sometimes |
271
+ | Ships a full DataTable | Yes | No (build it) | No | No | Partial (DataGrid is paid) |
272
+
273
+ ## Theming
274
+
275
+ Every component exposes its visual surface as CSS custom properties. Override on the component, on a parent class, or globally on `:root`.
91
276
 
92
- | | `@roy-ui/ui` | Radix / Headless UI | shadcn/ui |
93
- | --- | --- | --- | --- |
94
- | Ships visual styles | Yes | No | Yes (copy-paste) |
95
- | One install (no CLI, no copy) | Yes | Yes | No |
96
- | RSC-safe out of the box | Yes | Manual | Yes |
97
- | Tailwind required | No | No | Yes |
98
- | Animation built in | Yes | No | Sometimes |
277
+ ```css
278
+ .royui-table {
279
+ --royui-table-bg: #ffffff;
280
+ --royui-table-fg: #141414;
281
+ --royui-table-border: rgba(20, 20, 20, 0.1);
282
+ --royui-table-header-bg: #f7f7f7;
283
+ --royui-table-cell-size: 14px;
284
+ --royui-table-cell-font: 'Inter', system-ui, sans-serif;
285
+ }
286
+ ```
287
+
288
+ A dark scheme override ships under `@media (prefers-color-scheme: dark)` for every component.
289
+
290
+ ## Framework support
291
+
292
+ | Framework | Status |
293
+ | --- | --- |
294
+ | Next.js 13 / 14 / 15 (App Router) | Supported |
295
+ | Next.js (Pages Router) | Supported |
296
+ | Vite + React 18 / 19 | Supported |
297
+ | Remix | Supported |
298
+ | Astro (React island) | Supported |
299
+ | TanStack Start | Supported |
300
+ | Create React App | Supported |
301
+ | Plain React 18+ + ESM bundler | Supported |
302
+
303
+ ## FAQ
304
+
305
+ **Is this a free React data table library?**
306
+ Yes. MIT licensed, free for personal and commercial use, no paid tier.
307
+
308
+ **Does the DataTable work with React Server Components?**
309
+ Yes. The component carries its own `"use client"` boundary inside the published bundle, so you can render `<DataTable />` from a Next.js App Router server component without manually marking the file.
310
+
311
+ **Is Tailwind CSS required?**
312
+ No. Styles are scoped CSS, side-effect imported by each component. No Tailwind plugin, no PostCSS config, no theme provider.
313
+
314
+ **Can I use this with TanStack Table?**
315
+ Yes, but you don't need to — the DataTable here ships its own state pipeline (search → date filter → time filter → sort → paginate) and column-layout state (order, sizes, hidden). If you already use TanStack Table, use the `Table`, `TableHead`, `TableRow`, `TableCell` primitives from `@roy-ui/ui` for styles and wire your TanStack instance to them.
316
+
317
+ **How do I render every column without a horizontal scrollbar?**
318
+ Pass `fitColumns` to `<DataTable />` — columns will share the container width and cell content wraps instead of overflowing.
319
+
320
+ **Can I persist the user's column layout?**
321
+ Yes — pass `storageKey="orders-table"` to `<DataTable />` and column order, sizes, and hidden state are saved to `localStorage`.
322
+
323
+ **Is there a CSV import / export built in?**
324
+ Yes. `dataIO.export.enabled` adds an Export button; `dataIO.import.enabled` adds an Import button with a file picker. CSV writer is RFC 4180; parser handles quoted fields and escaped quotes. JSON IO is also built in. Bring your own parser via `dataIO.import.parse` for Excel / Parquet / etc.
99
325
 
100
326
  ## Links
101
327
 
102
- - **Source code:** https://github.com/DibbayajyotiRoy/RoyUI
103
- - **Issues:** https://github.com/DibbayajyotiRoy/RoyUI/issues
104
- - **Releases:** https://github.com/DibbayajyotiRoy/RoyUI/releases
105
- - **Demo video:** https://github.com/DibbayajyotiRoy/RoyUI/blob/main/apps/docs/lib/demo/linkedin2.mp4
328
+ - **Live documentation:** <https://royui.dev>
329
+ - **Source code:** <https://github.com/DibbayajyotiRoy/RoyUI>
330
+ - **Issues:** <https://github.com/DibbayajyotiRoy/RoyUI/issues>
331
+ - **Releases:** <https://github.com/DibbayajyotiRoy/RoyUI/releases>
332
+ - **npm:** <https://www.npmjs.com/package/@roy-ui/ui>
106
333
 
107
334
  ## License
108
335
 
109
336
  [MIT](https://github.com/DibbayajyotiRoy/RoyUI/blob/main/LICENSE) © [Dibbayajyoti Roy](https://github.com/DibbayajyotiRoy)
337
+
338
+ ---
339
+
340
+ <sub>
341
+ <strong>Keywords:</strong>
342
+ react data table · react data grid · react table component · react table library · react table with search and pagination · react table drag and drop columns · react resizable table · react table csv export · react table json export · react date range picker · custom react date picker · two month date range picker · react time picker · analog clock react · digital time picker react · react time range · react pagination component · react table primitives · headless table react · react component library · react ui library · react ui kit · typescript react components · next.js 15 components · next.js app router components · react server components · rsc-safe · vite react components · remix ui components · astro react components · tanstack start components · tanstack table alternative · ag-grid alternative · ag grid community alternative · material react table alternative · mui datagrid alternative · react table v7 alternative · react table v8 alternative · shadcn ui alternative · shadcn data table · aceternity ui alternative · magic ui alternative · radix alternative · headless ui alternative · chakra ui alternative · mantine alternative · daisyui alternative · react 18 · react 19 · esm only · tree shakable · zero config · animated react components · gradient button · animated gradient button · react popover · text morph · typing animation · react tree navigation · react sidebar nav · made by attribution badge · MIT · open source · free
343
+ </sub>