@adobe-commerce/elsie 1.6.0-alpha999 → 1.6.0-beta1

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.
@@ -0,0 +1,761 @@
1
+ /********************************************************************
2
+ * Copyright 2025 Adobe
3
+ * All Rights Reserved.
4
+ *
5
+ * NOTICE: Adobe permits you to use, modify, and distribute this
6
+ * file in accordance with the terms of the Adobe license agreement
7
+ * accompanying it.
8
+ *******************************************************************/
9
+
10
+ // https://storybook.js.org/docs/7.0/preact/writing-stories/introduction
11
+ import type { Meta, StoryObj } from '@storybook/preact';
12
+ import { useState } from 'preact/hooks';
13
+ import { Table as TableComponent, TableProps } from '@adobe-commerce/elsie/components/Table';
14
+
15
+ /**
16
+ * Use the `Table` component to render data in a structured table.
17
+ *
18
+ * ## Column Structure
19
+ * Each column in the `columns` array defines a table column with:
20
+ * - **`key`**: Unique identifier that matches the property names in `rowData` objects
21
+ * - **`label`**: Display text shown in the column header
22
+ * - **`sortBy`**: Optional sorting state (`true` for sortable but neutral, `'asc'` for ascending, `'desc'` for descending)
23
+ *
24
+ * ## Row Data Structure
25
+ * Each object in the `rowData` array represents a table row where:
26
+ * - **Keys** must match the `key` values from the `columns` array
27
+ * - **Values** can be:
28
+ * - **Strings**: Plain text content
29
+ * - **Numbers**: Numeric values (automatically converted to strings for display)
30
+ * - **VNode**: Preact `VNode` for complex content (buttons, icons, formatted text, etc.)
31
+ *
32
+ * ## Mobile Layout & Container Queries
33
+ * The table uses **container queries** instead of media queries for responsive behavior:
34
+ * - **`mobileLayout`**: Optional prop that controls mobile behavior
35
+ * - `'none'` (default): No special mobile layout
36
+ * - `'stacked'`: Stacks cells vertically when container width ≤ 600px
37
+ * - **Container Query Breakpoint**: 600px - triggers when the table's container becomes narrow
38
+ * - **`data-label`**: Automatically added to cells for accessibility in stacked layout
39
+ * - **Responsive Behavior**: Table adapts to its container width, not viewport width
40
+ *
41
+ * ## All props
42
+ * The table below shows all the props for the `Table` component.
43
+ */
44
+
45
+ const meta: Meta<TableProps> = {
46
+ title: 'Components/Table',
47
+ component: TableComponent,
48
+ parameters: {
49
+ layout: 'padded',
50
+ },
51
+ argTypes: {
52
+ columns: {
53
+ description: 'Array of column definitions for the table. Each column defines the structure and behavior of a table column.',
54
+ table: {
55
+ type: { summary: 'Column[]' },
56
+ },
57
+ control: 'object',
58
+ },
59
+ rowData: {
60
+ description: 'Array of data objects to display in table rows. Each object represents a table row where keys match column keys and values contain the cell content.',
61
+ table: {
62
+ type: { summary: 'RowData[]' },
63
+ },
64
+ control: 'object',
65
+ },
66
+ mobileLayout: {
67
+ description: 'Controls responsive layout behavior using container queries. When set to "stacked", cells stack vertically when the table container width ≤ 600px. The `data-label` attribute is automatically added to cells for accessibility.',
68
+ table: {
69
+ type: { summary: 'none | stacked' },
70
+ },
71
+ control: 'select',
72
+ options: ['none', 'stacked'],
73
+ mapping: {
74
+ none: 'none',
75
+ stacked: 'stacked',
76
+ },
77
+ },
78
+ caption: {
79
+ description: 'Optional table caption that provides context and description. Displays above the table and is announced by screen readers.',
80
+ table: {
81
+ type: { summary: 'string' },
82
+ },
83
+ control: 'text',
84
+ },
85
+ onSortChange: {
86
+ description: 'Callback function triggered when column sorting changes.',
87
+ table: {
88
+ type: { summary: '(columnKey: string, direction: Sortable) => void' },
89
+ },
90
+ action: 'onSortChange',
91
+ },
92
+ expandedRows: {
93
+ description: 'Set of row indices that are currently expanded. Used to control which rows are shown in expanded state. Row details will only render for rows that have `_rowDetails` content and are included in this set.',
94
+ table: {
95
+ type: { summary: 'Set<number>' },
96
+ },
97
+ control: 'object',
98
+ },
99
+ loading: {
100
+ description: 'When true, renders skeleton rows instead of actual data. Useful for showing loading state while data is being fetched.',
101
+ table: {
102
+ type: { summary: 'boolean' },
103
+ },
104
+ control: 'boolean',
105
+ },
106
+ skeletonRowCount: {
107
+ description: 'Number of skeleton rows to render when loading is true. Defaults to 10 rows.',
108
+ table: {
109
+ type: { summary: 'number' },
110
+ },
111
+ control: 'number',
112
+ },
113
+ },
114
+ };
115
+
116
+ export default meta;
117
+
118
+ type Story = StoryObj<TableProps>;
119
+
120
+ // Wrapper component to manage sorting state
121
+ const TableWithState = (args: TableProps) => {
122
+ const [columns, setColumns] = useState(args.columns);
123
+
124
+ const handleSortChange = (columnKey: string, direction: 'asc' | 'desc' | true) => {
125
+ // call Action onSortChange
126
+ args.onSortChange?.(columnKey, direction);
127
+
128
+ // Update column sort states
129
+ setColumns(prevColumns =>
130
+ prevColumns.map(col => {
131
+ if (col.key === columnKey) {
132
+ return { ...col, sortBy: direction };
133
+ } else if (col.sortBy === 'asc' || col.sortBy === 'desc') {
134
+ return { ...col, sortBy: true }; // Reset other sorted columns to neutral
135
+ }
136
+ return col;
137
+ })
138
+ );
139
+ };
140
+
141
+ return (
142
+ <TableComponent
143
+ {...args}
144
+ columns={columns}
145
+ onSortChange={handleSortChange}
146
+ />
147
+ );
148
+ };
149
+
150
+ /**
151
+ * Simple table.
152
+ * Demonstrates basic table structure with string and number content types.
153
+ *
154
+ *
155
+ * ```tsx
156
+ * <Table
157
+ * columns={[
158
+ * { key: 'name', label: 'Name' },
159
+ * { key: 'email', label: 'Email' },
160
+ * { key: 'age', label: 'Age' }
161
+ * ]}
162
+ * rowData={[
163
+ * { name: 'John', email: 'john@example.com', age: 20 },
164
+ * { name: 'Jane', email: 'jane@example.com', age: 21 }
165
+ * ]}
166
+ * />
167
+ * ```
168
+ */
169
+ export const Table: Story = {
170
+ args: {
171
+ columns: [
172
+ { key: 'name', label: 'Name' },
173
+ { key: 'email', label: 'Email' },
174
+ { key: 'age', label: 'Age' },
175
+ { key: 'actions', label: 'Actions' },
176
+ ],
177
+ rowData: [
178
+ { name: 'John', email: 'john@example.com', age: 20, actions: <button>Edit</button> },
179
+ { name: 'Jane', email: 'jane@example.com', age: 21, actions: <button>Edit</button> },
180
+ { name: 'Jim', email: 'jim@example.com', age: 22, actions: <button>Edit</button> },
181
+ { name: 'Jill', email: 'jill@example.com', age: 23, actions: <button>Edit</button> },
182
+ ],
183
+ },
184
+ };
185
+
186
+ /**
187
+ * Table where all columns are sortable. Demonstrates the three-state sorting cycle: `true` → `'asc'` → `'desc'` → `true`.
188
+ * Shows how multiple columns can be sortable simultaneously, with only one active sort at a time.
189
+ *
190
+ * ```tsx
191
+ * <Table
192
+ * columns={[
193
+ * { key: 'name', label: 'Name', sortBy: true },
194
+ * { key: 'email', label: 'Email', sortBy: true },
195
+ * { key: 'age', label: 'Age', sortBy: true }
196
+ * ]}
197
+ * rowData={[
198
+ * { name: 'John', email: 'john@example.com', age: 20 },
199
+ * { name: 'Jane', email: 'jane@example.com', age: 21 }
200
+ * ]}
201
+ * onSortChange={(columnKey, direction) => handleSort(columnKey, direction)}
202
+ * />
203
+ * ```
204
+ */
205
+ export const AllSortable: Story = {
206
+ render: TableWithState,
207
+ args: {
208
+ columns: [
209
+ { key: 'name', label: 'Name', sortBy: true },
210
+ { key: 'email', label: 'Email', sortBy: true },
211
+ { key: 'age', label: 'Age', sortBy: true },
212
+ { key: 'actions', label: 'Actions' },
213
+ ],
214
+ rowData: [
215
+ { name: 'John', email: 'john@example.com', age: 20, actions: <button>Edit</button> },
216
+ { name: 'Jane', email: 'jane@example.com', age: 21, actions: <button>Edit</button> },
217
+ { name: 'Jim', email: 'jim@example.com', age: 22, actions: <button>Edit</button> },
218
+ { name: 'Jill', email: 'jill@example.com', age: 23, actions: <button>Edit</button> },
219
+ { name: 'Jack', email: 'jack@example.com', age: 24, actions: <button>Edit</button> },
220
+ ],
221
+ },
222
+ };
223
+
224
+ /**
225
+ * Wide table with 10 columns to demonstrate horizontal scrolling and container query behavior.
226
+ * This table will show how the container query responds when the table becomes too wide for its container.
227
+ *
228
+ * ```tsx
229
+ * <Table
230
+ * columns={[
231
+ * { key: 'id', label: 'ID' },
232
+ * { key: 'name', label: 'Full Name' },
233
+ * { key: 'email', label: 'Email Address' },
234
+ * { key: 'phone', label: 'Phone Number' },
235
+ * { key: 'department', label: 'Department' },
236
+ * { key: 'position', label: 'Position' },
237
+ * { key: 'salary', label: 'Salary' },
238
+ * { key: 'startDate', label: 'Start Date' },
239
+ * { key: 'status', label: 'Status' },
240
+ * { key: 'actions', label: 'Actions' }
241
+ * ]}
242
+ * rowData={[
243
+ * { id: 1, name: 'John Doe', email: 'john@company.com', phone: '+1-555-0123', department: 'Engineering', position: 'Senior Developer', salary: '$95,000', startDate: '2022-01-15', status: 'Active', actions: <button>Edit</button> }
244
+ * ]}
245
+ * />
246
+ * ```
247
+ */
248
+ export const WideTable: Story = {
249
+ args: {
250
+ columns: [
251
+ { key: 'id', label: 'ID' },
252
+ { key: 'name', label: 'Full Name' },
253
+ { key: 'email', label: 'Email Address' },
254
+ { key: 'phone', label: 'Phone Number' },
255
+ { key: 'department', label: 'Department' },
256
+ { key: 'position', label: 'Position' },
257
+ { key: 'salary', label: 'Salary' },
258
+ { key: 'startDate', label: 'Start Date' },
259
+ { key: 'status', label: 'Status' },
260
+ { key: 'actions', label: 'Actions' },
261
+ ],
262
+ rowData: [
263
+ {
264
+ id: 1,
265
+ name: 'John Doe',
266
+ email: 'john.doe@company.com',
267
+ phone: '+1-555-0123',
268
+ department: 'Engineering',
269
+ position: 'Senior Developer',
270
+ salary: '$95,000',
271
+ startDate: '2022-01-15',
272
+ status: 'Active',
273
+ actions: <button>Edit</button>
274
+ },
275
+ {
276
+ id: 2,
277
+ name: 'Jane Smith',
278
+ email: 'jane.smith@company.com',
279
+ phone: '+1-555-0124',
280
+ department: 'Marketing',
281
+ position: 'Marketing Manager',
282
+ salary: '$78,000',
283
+ startDate: '2021-06-20',
284
+ status: 'Active',
285
+ actions: <button>Edit</button>
286
+ },
287
+ {
288
+ id: 3,
289
+ name: 'Bob Johnson',
290
+ email: 'bob.johnson@company.com',
291
+ phone: '+1-555-0125',
292
+ department: 'Sales',
293
+ position: 'Sales Director',
294
+ salary: '$110,000',
295
+ startDate: '2020-03-10',
296
+ status: 'Active',
297
+ actions: <button>Edit</button>
298
+ },
299
+ {
300
+ id: 4,
301
+ name: 'Alice Brown',
302
+ email: 'alice.brown@company.com',
303
+ phone: '+1-555-0126',
304
+ department: 'HR',
305
+ position: 'HR Specialist',
306
+ salary: '$65,000',
307
+ startDate: '2023-02-28',
308
+ status: 'Pending',
309
+ actions: <button>Edit</button>
310
+ },
311
+ {
312
+ id: 5,
313
+ name: 'Charlie Wilson',
314
+ email: 'charlie.wilson@company.com',
315
+ phone: '+1-555-0127',
316
+ department: 'Finance',
317
+ position: 'Financial Analyst',
318
+ salary: '$72,000',
319
+ startDate: '2022-09-12',
320
+ status: 'Active',
321
+ actions: <button>Edit</button>
322
+ },
323
+ ],
324
+ },
325
+ };
326
+
327
+ /**
328
+ * Table demonstrating complex VNode content in cells with multi-line text and interactive elements.
329
+ * This shows how the table handles rich content including buttons, badges, and formatted text.
330
+ *
331
+ * ```tsx
332
+ * <Table
333
+ * columns={[
334
+ * { key: 'user', label: 'User Info' },
335
+ * { key: 'description', label: 'Description' },
336
+ * { key: 'status', label: 'Status' },
337
+ * { key: 'actions', label: 'Actions' }
338
+ * ]}
339
+ * rowData={[
340
+ * {
341
+ * user: <div><strong>John Doe</strong><br/>john@example.com<br/>Senior Developer</div>,
342
+ * description: <div>Lead developer for the<br/>e-commerce platform<br/>with 5+ years experience</div>,
343
+ * status: <span>Active</span>,
344
+ * actions: <div><button>Edit</button><br/><button>Delete</button><br/><button>View</button></div>
345
+ * }
346
+ * ]}
347
+ * />
348
+ * ```
349
+ */
350
+ export const ComplexCells: Story = {
351
+ args: {
352
+ columns: [
353
+ { key: 'user', label: 'User Info' },
354
+ { key: 'description', label: 'Description' },
355
+ { key: 'status', label: 'Status' },
356
+ { key: 'actions', label: 'Actions' },
357
+ ],
358
+ rowData: [
359
+ {
360
+ user: (
361
+ <div>
362
+ <strong>John Doe</strong><br/>
363
+ john.doe@company.com<br/>
364
+ <em>Senior Developer</em>
365
+ </div>
366
+ ),
367
+ description: (
368
+ <div>
369
+ Lead developer for the<br/>
370
+ e-commerce platform<br/>
371
+ <small>with 5+ years experience</small>
372
+ </div>
373
+ ),
374
+ status: (
375
+ <span>Active</span>
376
+ ),
377
+ actions: (
378
+ <div>
379
+ <button>Edit</button>
380
+ <button>Delete</button>
381
+ <button>View</button>
382
+ </div>
383
+ ),
384
+ },
385
+ {
386
+ user: (
387
+ <div>
388
+ <strong>Jane Smith</strong><br/>
389
+ jane.smith@company.com<br/>
390
+ <em>Product Manager</em>
391
+ </div>
392
+ ),
393
+ description: (
394
+ <div>
395
+ Manages product roadmap<br/>
396
+ and feature planning<br/>
397
+ <small>3+ years in product</small>
398
+ </div>
399
+ ),
400
+ status: (
401
+ <span>Pending</span>
402
+ ),
403
+ actions: (
404
+ <div>
405
+ <button>Edit</button>
406
+ <button>Approve</button>
407
+ <button>Reject</button>
408
+ </div>
409
+ ),
410
+ },
411
+ {
412
+ user: (
413
+ <div>
414
+ <strong>Bob Johnson</strong><br/>
415
+ bob.johnson@company.com<br/>
416
+ <em>UX Designer</em>
417
+ </div>
418
+ ),
419
+ description: (
420
+ <div>
421
+ Designs user interfaces<br/>
422
+ and user experiences<br/>
423
+ <small>Expert in Figma & Sketch</small>
424
+ </div>
425
+ ),
426
+ status: (
427
+ <span>Inactive</span>
428
+ ),
429
+ actions: (
430
+ <div>
431
+ <button>Edit</button>
432
+ <button>Activate</button>
433
+ <button>Archive</button>
434
+ </div>
435
+ ),
436
+ },
437
+ ],
438
+ },
439
+ };
440
+
441
+ /**
442
+ * Table with stacked mobile layout that uses container queries.
443
+ * This demonstrates how the table adapts to its container width rather than viewport width.
444
+ * The table will stack vertically when its container becomes narrow (≤600px).
445
+ *
446
+ * **Container Query Behavior**: Uses `mobileLayout="stacked"` to enable responsive stacking.
447
+ * When the container width ≤ 600px:
448
+ * - Headers are hidden (`display: none`)
449
+ * - Cells stack vertically (`display: block`)
450
+ * - Column labels appear as `data-label` attributes before each cell value
451
+ * - Perfect for mobile views, sidebars, or constrained layouts
452
+ *
453
+ * ```tsx
454
+ * <Table
455
+ * mobileLayout="stacked"
456
+ * columns={[
457
+ * { key: 'name', label: 'Name' },
458
+ * { key: 'email', label: 'Email' },
459
+ * { key: 'age', label: 'Age' }
460
+ * ]}
461
+ * rowData={[
462
+ * { name: 'John', email: 'john@example.com', age: 20 },
463
+ * { name: 'Jane', email: 'jane@example.com', age: 21 }
464
+ * ]}
465
+ * />
466
+ * ```
467
+ */
468
+ export const StackedMobileLayout: Story = {
469
+ args: {
470
+ mobileLayout: 'stacked',
471
+ columns: [
472
+ { key: 'name', label: 'Name' },
473
+ { key: 'email', label: 'Email' },
474
+ { key: 'age', label: 'Age' },
475
+ { key: 'status', label: 'Status' },
476
+ { key: 'actions', label: 'Actions' },
477
+ ],
478
+ rowData: [
479
+ { name: 'John Doe', email: 'john.doe@example.com', age: 28, status: 'Active', actions: <button>Edit</button> },
480
+ { name: 'Jane Smith', email: 'jane.smith@example.com', age: 32, status: 'Inactive', actions: <button>Edit</button> },
481
+ { name: 'Bob Johnson', email: 'bob.johnson@example.com', age: 45, status: 'Active', actions: <button>Edit</button> },
482
+ { name: 'Alice Brown', email: 'alice.brown@example.com', age: 29, status: 'Pending', actions: <button>Edit</button> },
483
+ ],
484
+ },
485
+ };
486
+
487
+
488
+ /**
489
+ * Table with programmatically controlled expandable rows.
490
+ * Row expansion is controlled by buttons or other interactive elements within the column content.
491
+ * Developers must manage the `expandedRows` state themselves.
492
+ *
493
+ * **Features**:
494
+ * - Row details only render when both `_rowDetails` exists and row index is in `expandedRows`
495
+ * - Row details span the full width of the table
496
+ * - Supports any VNode content in the `_rowDetails` property
497
+ *
498
+ * ```tsx
499
+ * const [expandedRows, setExpandedRows] = useState(new Set());
500
+ *
501
+ * const toggleRow = (rowIndex: number) => {
502
+ * setExpandedRows(prev => {
503
+ * const newSet = new Set(prev);
504
+ * if (newSet.has(rowIndex)) {
505
+ * newSet.delete(rowIndex);
506
+ * } else {
507
+ * newSet.add(rowIndex);
508
+ * }
509
+ * return newSet;
510
+ * });
511
+ * };
512
+ *
513
+ * <Table
514
+ * columns={[
515
+ * { key: 'name', label: 'Name' },
516
+ * { key: 'email', label: 'Email' },
517
+ * { key: 'actions', label: 'Actions' }
518
+ * ]}
519
+ * rowData={[
520
+ * {
521
+ * name: 'John',
522
+ * email: 'john@example.com',
523
+ * actions: <button onClick={() => toggleRow(0)}>Toggle Details</button>,
524
+ * _rowDetails: <div>Additional information...</div>
525
+ * }
526
+ * ]}
527
+ * expandedRows={expandedRows}
528
+ * />
529
+ * ```
530
+ */
531
+ export const RowDetails: Story = {
532
+ render: (args) => {
533
+ const [expandedRows, setExpandedRows] = useState(new Set<number>());
534
+
535
+ const toggleRow = (rowIndex: number) => {
536
+ setExpandedRows(prev => {
537
+ const newSet = new Set(prev);
538
+ if (newSet.has(rowIndex)) {
539
+ newSet.delete(rowIndex);
540
+ } else {
541
+ newSet.add(rowIndex);
542
+ }
543
+ return newSet;
544
+ });
545
+ };
546
+
547
+ const rowData = [
548
+ {
549
+ name: 'John Doe',
550
+ email: 'john.doe@company.com',
551
+ status: 'Active',
552
+ actions: (
553
+ <button onClick={() => toggleRow(0)}>
554
+ {expandedRows.has(0) ? 'Hide' : 'Show'}
555
+ </button>
556
+ ),
557
+ _rowDetails: (
558
+ <div>
559
+ <h3>Employee Details</h3>
560
+ <p><strong>Department:</strong> Engineering</p>
561
+ <p><strong>Position:</strong> Senior Developer</p>
562
+ <p><strong>Start Date:</strong> January 15, 2022</p>
563
+ <p><strong>Notes:</strong> Excellent performance, leads the frontend team.</p>
564
+ <div style={{ marginTop: '12px' }}>
565
+ <button style={{ marginRight: '8px' }}>Update Details</button>
566
+ <button>View Full Profile</button>
567
+ </div>
568
+ </div>
569
+ )
570
+ },
571
+ {
572
+ name: 'Jane Smith',
573
+ email: 'jane.smith@company.com',
574
+ status: 'Pending',
575
+ actions: (
576
+ <button onClick={() => toggleRow(1)}>
577
+ {expandedRows.has(1) ? 'Hide' : 'Show'}
578
+ </button>
579
+ ),
580
+ _rowDetails: (
581
+ <div>
582
+ <h3>Pending Approval</h3>
583
+ <p><strong>Department:</strong> Marketing</p>
584
+ <p><strong>Position:</strong> Marketing Manager</p>
585
+ <p><strong>Application Date:</strong> December 1, 2024</p>
586
+ <p><strong>Status:</strong> Awaiting HR approval</p>
587
+ <div style={{ marginTop: '12px' }}>
588
+ <button style={{ marginRight: '8px', backgroundColor: '#22c55e', color: 'white', border: 'none', padding: '6px 12px', borderRadius: '4px' }}>Approve</button>
589
+ <button style={{ backgroundColor: '#ef4444', color: 'white', border: 'none', padding: '6px 12px', borderRadius: '4px' }}>Reject</button>
590
+ </div>
591
+ </div>
592
+ )
593
+ },
594
+ {
595
+ name: 'Bob Johnson',
596
+ email: 'bob.johnson@company.com',
597
+ status: 'Inactive',
598
+ actions: (
599
+ <button onClick={() => toggleRow(2)}>
600
+ {expandedRows.has(2) ? 'Hide' : 'Show'}
601
+ </button>
602
+ ),
603
+ _rowDetails: (
604
+ <div>
605
+ <h3>Account Information</h3>
606
+ <p><strong>Department:</strong> Sales</p>
607
+ <p><strong>Position:</strong> Sales Director</p>
608
+ <p><strong>Last Active:</strong> November 20, 2024</p>
609
+ <p><strong>Reason:</strong> On extended leave</p>
610
+ <div style={{ marginTop: '12px' }}>
611
+ <button style={{ marginRight: '8px' }}>Reactivate Account</button>
612
+ <button>Contact Employee</button>
613
+ </div>
614
+ </div>
615
+ )
616
+ },
617
+ ];
618
+
619
+ return (
620
+ <TableComponent
621
+ {...args}
622
+ columns={[
623
+ { key: 'name', label: 'Name' },
624
+ { key: 'email', label: 'Email' },
625
+ { key: 'status', label: 'Status' },
626
+ { key: 'actions', label: 'Actions' },
627
+ ]}
628
+ rowData={rowData}
629
+ expandedRows={expandedRows}
630
+ />
631
+ );
632
+ },
633
+ };
634
+
635
+ /**
636
+ * Table in loading state with skeleton rows.
637
+ * Demonstrates how the table appears while data is being fetched.
638
+ * Each cell shows a skeleton placeholder that matches the table structure.
639
+ *
640
+ * **Features**:
641
+ * - Shows skeleton rows instead of actual data when `loading` is true
642
+ * - Configurable number of skeleton rows via `skeletonRowCount` prop
643
+ * - Maintains table structure and column headers during loading
644
+ * - Each cell contains a single-line skeleton component
645
+ *
646
+ * ```tsx
647
+ * <Table
648
+ * loading={true}
649
+ * skeletonRowCount={5}
650
+ * columns={[
651
+ * { key: 'name', label: 'Name' },
652
+ * { key: 'email', label: 'Email' },
653
+ * { key: 'status', label: 'Status' }
654
+ * ]}
655
+ * rowData={[]} // Empty array when loading
656
+ * />
657
+ * ```
658
+ */
659
+ export const LoadingState: Story = {
660
+ args: {
661
+ loading: true,
662
+ skeletonRowCount: 5,
663
+ columns: [
664
+ { key: 'name', label: 'Name' },
665
+ { key: 'email', label: 'Email' },
666
+ { key: 'status', label: 'Status' },
667
+ { key: 'actions', label: 'Actions' },
668
+ ],
669
+ rowData: [], // Empty when loading
670
+ },
671
+ };
672
+
673
+ /**
674
+ * Table with VNode labels in column headers.
675
+ * Demonstrates how column labels can be VNode elements instead of simple strings.
676
+ * This allows for rich header content like icons, formatted text, or custom components.
677
+ *
678
+ * **Features**:
679
+ * - Column labels can be VNode elements (JSX components)
680
+ * - Supports any valid Preact VNode content in headers
681
+ * - Maintains all table functionality with custom header content
682
+ * - Useful for adding icons, tooltips, or formatted text to headers
683
+ *
684
+ * ```tsx
685
+ * <Table
686
+ * columns={[
687
+ * { key: 'name', label: <span><strong>👤 User Name</strong></span> },
688
+ * { key: 'email', label: <span style={{ color: '#0066cc' }}>📧 Email</span> },
689
+ * { key: 'status', label: <em>Status Info</em> }
690
+ * ]}
691
+ * rowData={[
692
+ * { name: 'John', email: 'john@example.com', status: 'Active' }
693
+ * ]}
694
+ * />
695
+ * ```
696
+ */
697
+ export const VNodeLabels: Story = {
698
+ args: {
699
+ columns: [
700
+ {
701
+ key: 'name',
702
+ label: (
703
+ <span>
704
+ <strong>👤 User Name</strong>
705
+ </span>
706
+ ),
707
+ },
708
+ {
709
+ key: 'email',
710
+ label: <span style={{ color: '#0066cc' }}>📧 Email Address</span>,
711
+ },
712
+ {
713
+ key: 'role',
714
+ label: <em style={{ color: '#666' }}>Role & Department</em>,
715
+ },
716
+ {
717
+ key: 'status',
718
+ label: (
719
+ <span
720
+ style={{
721
+ padding: '4px 8px',
722
+ backgroundColor: '#f0f9ff',
723
+ borderRadius: '4px',
724
+ fontSize: '12px',
725
+ }}
726
+ >
727
+ 📊 Status
728
+ </span>
729
+ ),
730
+ },
731
+ {
732
+ key: 'actions',
733
+ label: <span>⚙️ Actions</span>,
734
+ },
735
+ ],
736
+ rowData: [
737
+ {
738
+ name: 'John Doe',
739
+ email: 'john.doe@company.com',
740
+ role: 'Senior Developer',
741
+ status: 'Active',
742
+ actions: <button>Edit</button>,
743
+ },
744
+ {
745
+ name: 'Jane Smith',
746
+ email: 'jane.smith@company.com',
747
+ role: 'Product Manager',
748
+ status: 'Active',
749
+ actions: <button>Edit</button>,
750
+ },
751
+ {
752
+ name: 'Bob Johnson',
753
+ email: 'bob.johnson@company.com',
754
+ role: 'UX Designer',
755
+ status: 'Inactive',
756
+ actions: <button>Edit</button>,
757
+ },
758
+ ],
759
+ },
760
+ };
761
+