@aiaiai-pt/design-system 0.6.0 → 0.7.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.
@@ -27,6 +27,21 @@
27
27
 
28
28
  @example Loading
29
29
  <DataTable {columns} rows={[]} loading />
30
+
31
+ @example Custom cell rendering (badges, chips, components)
32
+ Pass a `cell` snippet to override the default per-cell text rendering.
33
+ The default behavior (using `column.render` to produce a string) is
34
+ preserved when no `cell` snippet is provided.
35
+
36
+ <DataTable {columns} {rows}>
37
+ {#snippet cell({ row, column, value })}
38
+ {#if column.key === 'status'}
39
+ <Badge variant={statusVariant(value)}>{value}</Badge>
40
+ {:else}
41
+ {value ?? '-'}
42
+ {/if}
43
+ {/snippet}
44
+ </DataTable>
30
45
  -->
31
46
  <script>
32
47
  /**
@@ -65,6 +80,23 @@
65
80
  on_select = undefined,
66
81
  /** @type {((row: Record<string, unknown>) => void) | undefined} */
67
82
  on_row_click = undefined,
83
+ /**
84
+ * Optional per-cell render override. When provided, called for every td
85
+ * with `{ row, column, value }`; the snippet's output replaces the
86
+ * default text rendering. When omitted, the default text path runs
87
+ * (`column.render` then `String(value)`) so existing consumers keep
88
+ * working unchanged.
89
+ *
90
+ * Why a snippet rather than passing a Svelte component class via
91
+ * `column.render`: snippets accept the full row context (not just the
92
+ * value), let consumers compose any DS primitive (Badge, Tag, Status,
93
+ * Button) without bringing those imports into the DS surface, and
94
+ * Svelte 5's snippet API is the canonical way to parameterize child
95
+ * rendering. `column.render` stays for the common string case.
96
+ *
97
+ * @type {import('svelte').Snippet<[{ row: Record<string, unknown>, column: ColumnDef, value: unknown }]> | undefined}
98
+ */
99
+ cell = undefined,
68
100
  /** @type {import('svelte').Snippet | undefined} */
69
101
  children = undefined,
70
102
  /** @type {string} */
@@ -258,7 +290,11 @@
258
290
  {/if}
259
291
  {#each columns as col}
260
292
  <td class="table-td">
261
- {render_cell(col, row[col.key], row)}
293
+ {#if cell}
294
+ {@render cell({ row, column: col, value: row[col.key] })}
295
+ {:else}
296
+ {render_cell(col, row[col.key], row)}
297
+ {/if}
262
298
  </td>
263
299
  {/each}
264
300
  </tr>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiaiai-pt/design-system",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Design system tokens and Svelte components for aiaiai products",
5
5
  "license": "MIT",
6
6
  "type": "module",