@classic-homes/theme-mcp 0.1.14 → 0.1.16
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/dist/cli.js +147 -248
- package/dist/cli.js.map +1 -1
- package/dist/index.js +147 -248
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2733,7 +2733,7 @@ var component_catalog_default = {
|
|
|
2733
2733
|
},
|
|
2734
2734
|
{
|
|
2735
2735
|
name: "DataTable",
|
|
2736
|
-
description: "Powerful data table with
|
|
2736
|
+
description: "Powerful data table with native Svelte 5 runes - sorting, filtering, pagination, virtualization, and inline editing",
|
|
2737
2737
|
category: "data",
|
|
2738
2738
|
importPath: "@classic-homes/theme-svelte",
|
|
2739
2739
|
props: [
|
|
@@ -2787,7 +2787,7 @@ var component_catalog_default = {
|
|
|
2787
2787
|
name: "onSort",
|
|
2788
2788
|
type: "(column: string, direction: 'asc' | 'desc') => void",
|
|
2789
2789
|
required: false,
|
|
2790
|
-
description: "Sort callback"
|
|
2790
|
+
description: "Sort callback (enables server-side sorting)"
|
|
2791
2791
|
},
|
|
2792
2792
|
{
|
|
2793
2793
|
name: "onRowClick",
|
|
@@ -2812,6 +2812,26 @@ var component_catalog_default = {
|
|
|
2812
2812
|
type: "string",
|
|
2813
2813
|
required: false,
|
|
2814
2814
|
description: "Additional classes"
|
|
2815
|
+
},
|
|
2816
|
+
{
|
|
2817
|
+
name: "enablePagination",
|
|
2818
|
+
type: "boolean",
|
|
2819
|
+
default: "false",
|
|
2820
|
+
required: false,
|
|
2821
|
+
description: "Enable built-in pagination"
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
name: "pageSize",
|
|
2825
|
+
type: "number",
|
|
2826
|
+
default: "10",
|
|
2827
|
+
required: false,
|
|
2828
|
+
description: "Rows per page"
|
|
2829
|
+
},
|
|
2830
|
+
{
|
|
2831
|
+
name: "getRowId",
|
|
2832
|
+
type: "(row: T, index: number) => string",
|
|
2833
|
+
required: false,
|
|
2834
|
+
description: "Function to get unique row ID"
|
|
2815
2835
|
}
|
|
2816
2836
|
],
|
|
2817
2837
|
variants: [
|
|
@@ -2841,92 +2861,104 @@ var component_catalog_default = {
|
|
|
2841
2861
|
events: [],
|
|
2842
2862
|
examples: [
|
|
2843
2863
|
{
|
|
2844
|
-
title: "Creating a
|
|
2864
|
+
title: "Creating a Table Instance",
|
|
2845
2865
|
code: `<script lang="ts">
|
|
2846
2866
|
import {
|
|
2847
2867
|
createDataTable,
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
type
|
|
2868
|
+
DataTableToolbar,
|
|
2869
|
+
DataTablePagination,
|
|
2870
|
+
type DataTableColumn,
|
|
2851
2871
|
} from '@classic-homes/theme-svelte';
|
|
2852
2872
|
|
|
2853
2873
|
interface User {
|
|
2854
2874
|
id: number;
|
|
2855
2875
|
name: string;
|
|
2856
2876
|
email: string;
|
|
2877
|
+
role: string;
|
|
2857
2878
|
}
|
|
2858
2879
|
|
|
2859
|
-
//
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2880
|
+
// Column definitions
|
|
2881
|
+
const columns: DataTableColumn<User>[] = [
|
|
2882
|
+
{ id: 'id', header: 'ID', accessor: 'id', sortable: true },
|
|
2883
|
+
{ id: 'name', header: 'Name', accessor: 'name', sortable: true },
|
|
2884
|
+
{ id: 'email', header: 'Email', accessor: 'email', sortable: true },
|
|
2885
|
+
{
|
|
2886
|
+
id: 'role',
|
|
2887
|
+
header: 'Role',
|
|
2888
|
+
accessor: 'role',
|
|
2889
|
+
filterOptions: [
|
|
2890
|
+
{ value: 'Admin', label: 'Admin' },
|
|
2891
|
+
{ value: 'Editor', label: 'Editor' },
|
|
2892
|
+
{ value: 'Viewer', label: 'Viewer' },
|
|
2893
|
+
],
|
|
2894
|
+
},
|
|
2868
2895
|
];
|
|
2869
2896
|
|
|
2870
2897
|
// Create table instance
|
|
2871
|
-
const
|
|
2898
|
+
const table = createDataTable<User>(() => ({
|
|
2872
2899
|
data: users,
|
|
2873
2900
|
columns,
|
|
2874
|
-
|
|
2875
|
-
onSortingChange: (updater) => {
|
|
2876
|
-
sorting = typeof updater === 'function' ? updater(sorting) : updater;
|
|
2877
|
-
},
|
|
2878
|
-
onRowSelectionChange: (updater) => {
|
|
2879
|
-
rowSelection = typeof updater === 'function' ? updater(rowSelection) : updater;
|
|
2880
|
-
},
|
|
2881
|
-
enableRowSelection: true,
|
|
2882
|
-
enableSorting: true,
|
|
2901
|
+
getRowId: (row) => String(row.id),
|
|
2883
2902
|
}));
|
|
2903
|
+
</script>
|
|
2904
|
+
|
|
2905
|
+
<!-- Toolbar with search and filters -->
|
|
2906
|
+
<DataTableToolbar {table} />
|
|
2907
|
+
|
|
2908
|
+
<!-- Table rendering -->
|
|
2909
|
+
<table>
|
|
2910
|
+
<thead>
|
|
2911
|
+
<tr>
|
|
2912
|
+
{#each table.columns as column}
|
|
2913
|
+
<th onclick={() => column.sortable && table.toggleSort(column.id)}>
|
|
2914
|
+
{column.header}
|
|
2915
|
+
</th>
|
|
2916
|
+
{/each}
|
|
2917
|
+
</tr>
|
|
2918
|
+
</thead>
|
|
2919
|
+
<tbody>
|
|
2920
|
+
{#each table.rows as row}
|
|
2921
|
+
<tr>
|
|
2922
|
+
{#each table.columns as column}
|
|
2923
|
+
<td>{table.getFormattedCellValue(row.original, column)}</td>
|
|
2924
|
+
{/each}
|
|
2925
|
+
</tr>
|
|
2926
|
+
{/each}
|
|
2927
|
+
</tbody>
|
|
2928
|
+
</table>
|
|
2884
2929
|
|
|
2885
|
-
|
|
2886
|
-
|
|
2930
|
+
<!-- Pagination -->
|
|
2931
|
+
<DataTablePagination {table} />`
|
|
2887
2932
|
},
|
|
2888
2933
|
{
|
|
2889
2934
|
title: "Row Selection",
|
|
2890
2935
|
description: "Enable checkbox selection for rows:",
|
|
2891
|
-
code: "<script>\n let rowSelection = $state<
|
|
2936
|
+
code: "<script>\n let rowSelection = $state<Set<string>>(new Set());\n\n const table = createDataTable<User>(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n onRowSelectionChange: (selection) => {\n rowSelection = selection;\n },\n }));\n</script>\n\n<!-- Render checkbox in header -->\n<th>\n <Checkbox\n checked={table.isAllSelected}\n indeterminate={table.isSomeSelected}\n onCheckedChange={() => table.toggleAllRows()}\n />\n</th>\n\n<!-- Render checkbox in each row -->\n{#each table.rows as row}\n <td>\n <Checkbox checked={row.isSelected} onCheckedChange={() => table.toggleRowSelection(row.id)} />\n </td>\n{/each}"
|
|
2892
2937
|
},
|
|
2893
2938
|
{
|
|
2894
2939
|
title: "Column Visibility",
|
|
2895
2940
|
description: "Allow users to toggle column visibility:",
|
|
2896
|
-
code: "<script>\n let columnVisibility = $state<
|
|
2941
|
+
code: "<script>\n let columnVisibility = $state<Set<string>>(new Set());\n\n const table = createDataTable<User>(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n onColumnVisibilityChange: (hidden) => {\n columnVisibility = hidden;\n },\n }));\n</script>\n\n<!-- DataTableToolbar includes column visibility dropdown -->\n<DataTableToolbar {table} />"
|
|
2897
2942
|
},
|
|
2898
2943
|
{
|
|
2899
2944
|
title: "Global Search",
|
|
2900
2945
|
description: "Filter across all columns:",
|
|
2901
|
-
code: "<script>\n let globalFilter = $state('');\n\n const
|
|
2946
|
+
code: "<script>\n let globalFilter = $state('');\n\n const table = createDataTable<User>(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n onGlobalFilterChange: (filter) => {\n globalFilter = filter;\n },\n }));\n</script>\n\n<!-- DataTableToolbar includes a search input -->\n<DataTableToolbar {table} />"
|
|
2902
2947
|
},
|
|
2903
2948
|
{
|
|
2904
2949
|
title: "Column Filters",
|
|
2905
2950
|
description: "Filter individual columns with faceted filtering:",
|
|
2906
|
-
code: "<script>\n
|
|
2907
|
-
},
|
|
2908
|
-
{
|
|
2909
|
-
title: "Pagination",
|
|
2910
|
-
description: "Add pagination controls:",
|
|
2911
|
-
code: "<script>\n const tableApi = createDataTable<User>(() => ({\n data: users,\n columns,\n // Pagination is enabled by default\n }));\n</script>\n\n<!-- Table content -->\n<table>...</table>\n\n<!-- Pagination controls -->\n<DataTablePagination {table} />"
|
|
2951
|
+
code: "<script>\n const columns: DataTableColumn<User>[] = [\n {\n id: 'role',\n header: 'Role',\n accessor: 'role',\n filterOptions: [\n { value: 'Admin', label: 'Admin' },\n { value: 'Editor', label: 'Editor' },\n { value: 'Viewer', label: 'Viewer' },\n ],\n },\n {\n id: 'status',\n header: 'Status',\n accessor: 'status',\n filterOptions: [\n { value: 'active', label: 'Active' },\n { value: 'inactive', label: 'Inactive' },\n ],\n },\n ];\n\n const table = createDataTable<User>(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n }));\n</script>\n\n<!-- DataTableToolbar renders filter dropdowns for columns with filterOptions -->\n<DataTableToolbar {table} />"
|
|
2912
2952
|
},
|
|
2913
2953
|
{
|
|
2914
2954
|
title: "Virtualization",
|
|
2915
2955
|
description: "Render thousands of rows efficiently:",
|
|
2916
|
-
code: '<script>\n const
|
|
2956
|
+
code: '<script>\n const table = createDataTable<User>(() => ({\n data: largeDataset, // 10,000+ rows\n columns,\n getRowId: (row) => String(row.id),\n manualPagination: true, // Disable pagination for virtualization\n }));\n</script>\n\n<DataTableVirtual\n {table}\n rowHeight={48}\n overscan={10}\n height="500px"\n onRowClick={(row) => console.log(row)}\n/>'
|
|
2917
2957
|
},
|
|
2918
2958
|
{
|
|
2919
2959
|
title: "Inline Editing",
|
|
2920
2960
|
description: "Enable double-click cell editing:",
|
|
2921
|
-
code: "<script>\n function handleCellEdit(rowId: string, columnId: string, value: unknown, row: User) {\n // Update your data source\n const index = users.findIndex((u) => u.id ===
|
|
2922
|
-
},
|
|
2923
|
-
{
|
|
2924
|
-
title: "User Management Table",
|
|
2925
|
-
code: "<script>\n const columns = [\n { id: 'name', header: 'Name', accessor: 'name', sortable: true },\n { id: 'email', header: 'Email', accessor: 'email', sortable: true },\n { id: 'role', header: 'Role', accessor: 'role' },\n {\n id: 'joined',\n header: 'Joined',\n accessor: 'createdAt',\n sortable: true,\n format: (v) => new Date(v).toLocaleDateString(),\n },\n ];\n</script>\n\n<DataTable\n data={users}\n {columns}\n caption=\"User management table\"\n onRowClick={(user) => goto(`/users/${user.id}`)}\n/>"
|
|
2926
|
-
},
|
|
2927
|
-
{
|
|
2928
|
-
title: "Product Inventory",
|
|
2929
|
-
code: "<script>\n const columns = [\n { id: 'sku', header: 'SKU', accessor: 'sku', width: '120px' },\n { id: 'name', header: 'Product', accessor: 'name', sortable: true },\n {\n id: 'stock',\n header: 'Stock',\n accessor: 'quantity',\n align: 'right',\n sortable: true,\n },\n {\n id: 'price',\n header: 'Price',\n accessor: 'price',\n align: 'right',\n format: (v) => `$${v.toFixed(2)}`,\n },\n ];\n</script>\n\n<DataTable data={products} {columns} emptyMessage=\"No products found\" />"
|
|
2961
|
+
code: "<script>\n function handleCellEdit(rowId: string, columnId: string, value: unknown, row: User) {\n // Update your data source\n const index = users.findIndex((u) => String(u.id) === rowId);\n if (index !== -1) {\n users[index] = { ...users[index], [columnId]: value };\n }\n }\n\n const columns: DataTableColumn<User>[] = [\n { id: 'name', header: 'Name', accessor: 'name', enableEditing: true },\n { id: 'email', header: 'Email', accessor: 'email', enableEditing: true },\n ];\n</script>\n\n{#each table.rows as row}\n <tr>\n {#each table.columns as column}\n <td>\n <DataTableEditableCell {row} {column} onSave={handleCellEdit} />\n </td>\n {/each}\n </tr>\n{/each}"
|
|
2930
2962
|
}
|
|
2931
2963
|
],
|
|
2932
2964
|
relatedComponents: [
|
|
@@ -2942,12 +2974,19 @@ var component_catalog_default = {
|
|
|
2942
2974
|
category: "data",
|
|
2943
2975
|
importPath: "@classic-homes/theme-svelte",
|
|
2944
2976
|
props: [
|
|
2977
|
+
{
|
|
2978
|
+
name: "table",
|
|
2979
|
+
type: "DataTableInstance<T>",
|
|
2980
|
+
default: "**required**",
|
|
2981
|
+
required: false,
|
|
2982
|
+
description: "The table instance from createDataTable"
|
|
2983
|
+
},
|
|
2945
2984
|
{
|
|
2946
2985
|
name: "column",
|
|
2947
|
-
type: "
|
|
2986
|
+
type: "DataTableColumn<T>",
|
|
2948
2987
|
default: "**required**",
|
|
2949
2988
|
required: false,
|
|
2950
|
-
description: "The
|
|
2989
|
+
description: "The column to filter"
|
|
2951
2990
|
},
|
|
2952
2991
|
{
|
|
2953
2992
|
name: "placeholder",
|
|
@@ -2982,23 +3021,23 @@ var component_catalog_default = {
|
|
|
2982
3021
|
examples: [
|
|
2983
3022
|
{
|
|
2984
3023
|
title: "Basic Usage",
|
|
2985
|
-
code: "<script>\n import { createDataTable, DataTableColumnFilter } from '@classic-homes/theme-svelte';\n\n
|
|
3024
|
+
code: "<script>\n import { createDataTable, DataTableColumnFilter } from '@classic-homes/theme-svelte';\n\n const table = createDataTable(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n }));\n\n // Get a specific column for filtering\n const nameColumn = $derived(table.columns.find((c) => c.id === 'name'));\n</script>\n\n<!-- Filter for the name column -->\n{#if nameColumn}\n <DataTableColumnFilter {table} column={nameColumn} />\n{/if}"
|
|
2986
3025
|
},
|
|
2987
3026
|
{
|
|
2988
3027
|
title: "Custom Placeholder",
|
|
2989
|
-
code: '<DataTableColumnFilter {column} placeholder="Search names..." />'
|
|
3028
|
+
code: '<DataTableColumnFilter {table} {column} placeholder="Search names..." />'
|
|
2990
3029
|
},
|
|
2991
3030
|
{
|
|
2992
3031
|
title: "Faster Debounce",
|
|
2993
|
-
code: "<DataTableColumnFilter {column} debounceMs={150} />"
|
|
3032
|
+
code: "<DataTableColumnFilter {table} {column} debounceMs={150} />"
|
|
2994
3033
|
},
|
|
2995
3034
|
{
|
|
2996
3035
|
title: "In Table Header",
|
|
2997
|
-
code: '<thead>\n <tr>\n {#each table.
|
|
3036
|
+
code: '<thead>\n <tr>\n {#each table.columns as column}\n <th>\n {column.header}\n <DataTableColumnFilter {table} {column} class="mt-1" />\n </th>\n {/each}\n </tr>\n</thead>'
|
|
2998
3037
|
},
|
|
2999
3038
|
{
|
|
3000
3039
|
title: "Multiple Column Filters",
|
|
3001
|
-
code: '<div class="flex gap-2">\n {#each table.
|
|
3040
|
+
code: '<div class="flex gap-2">\n {#each table.columns as column}\n <DataTableColumnFilter {table} {column} class="w-40" />\n {/each}\n</div>'
|
|
3002
3041
|
}
|
|
3003
3042
|
],
|
|
3004
3043
|
relatedComponents: [
|
|
@@ -3015,16 +3054,10 @@ var component_catalog_default = {
|
|
|
3015
3054
|
props: [
|
|
3016
3055
|
{
|
|
3017
3056
|
name: "table",
|
|
3018
|
-
type: "
|
|
3057
|
+
type: "DataTableInstance<T>",
|
|
3019
3058
|
default: "**required**",
|
|
3020
3059
|
required: false,
|
|
3021
|
-
description: "The
|
|
3022
|
-
},
|
|
3023
|
-
{
|
|
3024
|
-
name: "visibilityState",
|
|
3025
|
-
type: "VisibilityState",
|
|
3026
|
-
required: false,
|
|
3027
|
-
description: "Optional visibility state for reactivity"
|
|
3060
|
+
description: "The table instance from createDataTable"
|
|
3028
3061
|
},
|
|
3029
3062
|
{
|
|
3030
3063
|
name: "class",
|
|
@@ -3045,20 +3078,15 @@ var component_catalog_default = {
|
|
|
3045
3078
|
examples: [
|
|
3046
3079
|
{
|
|
3047
3080
|
title: "Basic Usage",
|
|
3048
|
-
code: "<script>\n import { createDataTable, DataTableColumnVisibility } from '@classic-homes/theme-svelte';\n\n let columnVisibility = $state(
|
|
3081
|
+
code: "<script>\n import { createDataTable, DataTableColumnVisibility } from '@classic-homes/theme-svelte';\n\n let columnVisibility = $state<Set<string>>(new Set());\n\n const table = createDataTable(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n onColumnVisibilityChange: (hidden) => {\n columnVisibility = hidden;\n },\n }));\n</script>\n\n<DataTableColumnVisibility {table} />"
|
|
3049
3082
|
},
|
|
3050
3083
|
{
|
|
3051
|
-
title: "With
|
|
3052
|
-
|
|
3053
|
-
code: "<script>\n let columnVisibility = $state({\n email: false, // Hide email column by default\n phone: false, // Hide phone column by default\n });\n</script>\n\n<DataTableColumnVisibility {table} visibilityState={columnVisibility} />"
|
|
3084
|
+
title: "With Initial Hidden Columns",
|
|
3085
|
+
code: "<script>\n const table = createDataTable(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n initialHiddenColumns: ['email', 'phone'], // Hide these by default\n }));\n</script>\n\n<DataTableColumnVisibility {table} />"
|
|
3054
3086
|
},
|
|
3055
3087
|
{
|
|
3056
3088
|
title: "In Toolbar",
|
|
3057
3089
|
code: '<div class="flex items-center gap-2">\n <DataTableSearch {table} />\n <DataTableColumnVisibility {table} />\n</div>'
|
|
3058
|
-
},
|
|
3059
|
-
{
|
|
3060
|
-
title: "Hide Specific Columns Initially",
|
|
3061
|
-
code: "<script>\n // Some columns hidden by default\n let columnVisibility = $state({\n createdAt: false,\n updatedAt: false,\n internalId: false,\n });\n\n const tableApi = createDataTable(() => ({\n data,\n columns,\n state: { columnVisibility },\n onColumnVisibilityChange: (updater) => {\n columnVisibility = typeof updater === 'function' ? updater(columnVisibility) : updater;\n },\n enableHiding: true,\n }));\n</script>\n\n<DataTableColumnVisibility {table} visibilityState={columnVisibility} />"
|
|
3062
3090
|
}
|
|
3063
3091
|
],
|
|
3064
3092
|
relatedComponents: [
|
|
@@ -3074,18 +3102,18 @@ var component_catalog_default = {
|
|
|
3074
3102
|
importPath: "@classic-homes/theme-svelte",
|
|
3075
3103
|
props: [
|
|
3076
3104
|
{
|
|
3077
|
-
name: "
|
|
3078
|
-
type: "
|
|
3105
|
+
name: "row",
|
|
3106
|
+
type: "DataTableRow<T>",
|
|
3079
3107
|
default: "**required**",
|
|
3080
3108
|
required: false,
|
|
3081
|
-
description: "The
|
|
3109
|
+
description: "The row object from table.rows"
|
|
3082
3110
|
},
|
|
3083
3111
|
{
|
|
3084
|
-
name: "
|
|
3085
|
-
type: "T",
|
|
3112
|
+
name: "column",
|
|
3113
|
+
type: "DataTableColumn<T>",
|
|
3086
3114
|
default: "**required**",
|
|
3087
3115
|
required: false,
|
|
3088
|
-
description: "The
|
|
3116
|
+
description: "The column definition"
|
|
3089
3117
|
},
|
|
3090
3118
|
{
|
|
3091
3119
|
name: "onSave",
|
|
@@ -3113,21 +3141,25 @@ var component_catalog_default = {
|
|
|
3113
3141
|
examples: [
|
|
3114
3142
|
{
|
|
3115
3143
|
title: "Basic Usage",
|
|
3116
|
-
code: "<script>\n import { createDataTable, DataTableEditableCell } from '@classic-homes/theme-svelte';\n\n function handleCellEdit(rowId, columnId, value, row) {\n // Update your data source\n const index = users.findIndex((u) => u.id ===
|
|
3144
|
+
code: "<script>\n import { createDataTable, DataTableEditableCell } from '@classic-homes/theme-svelte';\n\n function handleCellEdit(rowId, columnId, value, row) {\n // Update your data source\n const index = users.findIndex((u) => String(u.id) === rowId);\n if (index !== -1) {\n users[index] = { ...users[index], [columnId]: value };\n }\n }\n\n const columns = [\n { id: 'name', header: 'Name', accessor: 'name', enableEditing: true },\n { id: 'email', header: 'Email', accessor: 'email', enableEditing: true },\n { id: 'role', header: 'Role', accessor: 'role' }, // Not editable\n ];\n\n const table = createDataTable(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n }));\n</script>\n\n{#each table.rows as row}\n <tr>\n {#each table.columns as column}\n <td>\n <DataTableEditableCell {row} {column} onSave={handleCellEdit} />\n </td>\n {/each}\n </tr>\n{/each}"
|
|
3117
3145
|
},
|
|
3118
3146
|
{
|
|
3119
3147
|
title: "With Custom Formatting",
|
|
3120
3148
|
description: "Cells can have custom display formatting while editing the raw value:",
|
|
3121
|
-
code: "<script>\n const columns = [\n {\n
|
|
3149
|
+
code: "<script>\n const columns = [\n {\n id: 'price',\n header: 'Price',\n accessor: 'price',\n enableEditing: true,\n format: (value) => `$${Number(value).toFixed(2)}`,\n },\n ];\n</script>"
|
|
3122
3150
|
},
|
|
3123
3151
|
{
|
|
3124
3152
|
title: "Async Save Handler",
|
|
3125
|
-
code: "<script>\n async function handleCellEdit(rowId, columnId, value, row) {\n try {\n await api.updateUser(row.id, { [columnId]: value });\n // Update local state after successful save\n users = users.map((u) => (u.id ===
|
|
3153
|
+
code: "<script>\n async function handleCellEdit(rowId, columnId, value, row) {\n try {\n await api.updateUser(row.id, { [columnId]: value });\n // Update local state after successful save\n users = users.map((u) => (String(u.id) === rowId ? { ...u, [columnId]: value } : u));\n } catch (error) {\n console.error('Failed to save:', error);\n // Optionally show error toast\n }\n }\n</script>"
|
|
3154
|
+
},
|
|
3155
|
+
{
|
|
3156
|
+
title: "With Type Conversion",
|
|
3157
|
+
code: "<script>\n function handleCellEdit(rowId, columnId, value, row) {\n let parsedValue = value;\n\n // Convert to number for numeric columns\n if (columnId === 'salary' || columnId === 'quantity') {\n parsedValue = parseInt(String(value), 10) || 0;\n }\n\n const index = data.findIndex((item) => String(item.id) === rowId);\n if (index !== -1) {\n data[index] = { ...data[index], [columnId]: parsedValue };\n }\n }\n</script>"
|
|
3126
3158
|
}
|
|
3127
3159
|
],
|
|
3128
3160
|
relatedComponents: [
|
|
3129
3161
|
"DataTable",
|
|
3130
|
-
"
|
|
3162
|
+
"DataTableVirtual"
|
|
3131
3163
|
]
|
|
3132
3164
|
},
|
|
3133
3165
|
{
|
|
@@ -3137,11 +3169,18 @@ var component_catalog_default = {
|
|
|
3137
3169
|
importPath: "@classic-homes/theme-svelte",
|
|
3138
3170
|
props: [
|
|
3139
3171
|
{
|
|
3140
|
-
name: "
|
|
3141
|
-
type: "
|
|
3172
|
+
name: "table",
|
|
3173
|
+
type: "DataTableInstance<T>",
|
|
3174
|
+
default: "**required**",
|
|
3175
|
+
required: false,
|
|
3176
|
+
description: "The table instance from createDataTable"
|
|
3177
|
+
},
|
|
3178
|
+
{
|
|
3179
|
+
name: "columnId",
|
|
3180
|
+
type: "string",
|
|
3142
3181
|
default: "**required**",
|
|
3143
3182
|
required: false,
|
|
3144
|
-
description: "The
|
|
3183
|
+
description: "The column ID to filter"
|
|
3145
3184
|
},
|
|
3146
3185
|
{
|
|
3147
3186
|
name: "title",
|
|
@@ -3179,24 +3218,16 @@ var component_catalog_default = {
|
|
|
3179
3218
|
code: `<script>
|
|
3180
3219
|
import { createDataTable, DataTableFacetedFilter } from '@classic-homes/theme-svelte';
|
|
3181
3220
|
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
const tableApi = createDataTable(() => ({
|
|
3221
|
+
const table = createDataTable(() => ({
|
|
3185
3222
|
data: users,
|
|
3186
3223
|
columns,
|
|
3187
|
-
|
|
3188
|
-
onColumnFiltersChange: (updater) => {
|
|
3189
|
-
columnFilters = typeof updater === 'function' ? updater(columnFilters) : updater;
|
|
3190
|
-
},
|
|
3191
|
-
enableColumnFilters: true,
|
|
3224
|
+
getRowId: (row) => String(row.id),
|
|
3192
3225
|
}));
|
|
3193
|
-
|
|
3194
|
-
const table = $derived(tableApi.instance);
|
|
3195
|
-
const statusColumn = $derived(table.getColumn('status'));
|
|
3196
3226
|
</script>
|
|
3197
3227
|
|
|
3198
3228
|
<DataTableFacetedFilter
|
|
3199
|
-
|
|
3229
|
+
{table}
|
|
3230
|
+
columnId="status"
|
|
3200
3231
|
title="Status"
|
|
3201
3232
|
options={[
|
|
3202
3233
|
{ value: 'active', label: 'Active' },
|
|
@@ -3223,59 +3254,19 @@ var component_catalog_default = {
|
|
|
3223
3254
|
]);
|
|
3224
3255
|
</script>
|
|
3225
3256
|
|
|
3226
|
-
<DataTableFacetedFilter
|
|
3257
|
+
<DataTableFacetedFilter {table} columnId="status" title="Status" options={statusOptions} />`
|
|
3227
3258
|
},
|
|
3228
3259
|
{
|
|
3229
3260
|
title: "Multiple Filters",
|
|
3230
|
-
code:
|
|
3231
|
-
<DataTableFacetedFilter
|
|
3232
|
-
column={table.getColumn('status')}
|
|
3233
|
-
title="Status"
|
|
3234
|
-
options={statusOptions}
|
|
3235
|
-
/>
|
|
3236
|
-
<DataTableFacetedFilter column={table.getColumn('role')} title="Role" options={roleOptions} />
|
|
3237
|
-
<DataTableFacetedFilter
|
|
3238
|
-
column={table.getColumn('department')}
|
|
3239
|
-
title="Department"
|
|
3240
|
-
options={departmentOptions}
|
|
3241
|
-
/>
|
|
3242
|
-
</div>`
|
|
3261
|
+
code: '<div class="flex gap-2">\n <DataTableFacetedFilter {table} columnId="status" title="Status" options={statusOptions} />\n <DataTableFacetedFilter {table} columnId="role" title="Role" options={roleOptions} />\n <DataTableFacetedFilter\n {table}\n columnId="department"\n title="Department"\n options={departmentOptions}\n />\n</div>'
|
|
3243
3262
|
},
|
|
3244
3263
|
{
|
|
3245
3264
|
title: "In DataTableToolbar",
|
|
3246
|
-
code:
|
|
3247
|
-
{#snippet filters()}
|
|
3248
|
-
<DataTableFacetedFilter
|
|
3249
|
-
column={table.getColumn('status')}
|
|
3250
|
-
title="Status"
|
|
3251
|
-
options={statusOptions}
|
|
3252
|
-
/>
|
|
3253
|
-
<DataTableFacetedFilter
|
|
3254
|
-
column={table.getColumn('priority')}
|
|
3255
|
-
title="Priority"
|
|
3256
|
-
options={priorityOptions}
|
|
3257
|
-
/>
|
|
3258
|
-
{/snippet}
|
|
3259
|
-
</DataTableToolbar>`
|
|
3265
|
+
code: '<DataTableToolbar {table}>\n {#snippet filters()}\n <DataTableFacetedFilter {table} columnId="status" title="Status" options={statusOptions} />\n <DataTableFacetedFilter\n {table}\n columnId="priority"\n title="Priority"\n options={priorityOptions}\n />\n {/snippet}\n</DataTableToolbar>'
|
|
3260
3266
|
},
|
|
3261
3267
|
{
|
|
3262
3268
|
title: "Dynamic Options from Data",
|
|
3263
|
-
code:
|
|
3264
|
-
// Extract unique values from data
|
|
3265
|
-
const uniqueStatuses = $derived(
|
|
3266
|
-
[...new Set(users.map((u) => u.status))].map((status) => ({
|
|
3267
|
-
value: status,
|
|
3268
|
-
label: status.charAt(0).toUpperCase() + status.slice(1),
|
|
3269
|
-
count: users.filter((u) => u.status === status).length,
|
|
3270
|
-
}))
|
|
3271
|
-
);
|
|
3272
|
-
</script>
|
|
3273
|
-
|
|
3274
|
-
<DataTableFacetedFilter
|
|
3275
|
-
column={table.getColumn('status')}
|
|
3276
|
-
title="Status"
|
|
3277
|
-
options={uniqueStatuses}
|
|
3278
|
-
/>`
|
|
3269
|
+
code: '<script>\n // Extract unique values from data\n const uniqueStatuses = $derived(\n [...new Set(users.map((u) => u.status))].map((status) => ({\n value: status,\n label: status.charAt(0).toUpperCase() + status.slice(1),\n count: users.filter((u) => u.status === status).length,\n }))\n );\n</script>\n\n<DataTableFacetedFilter {table} columnId="status" title="Status" options={uniqueStatuses} />'
|
|
3279
3270
|
}
|
|
3280
3271
|
],
|
|
3281
3272
|
relatedComponents: [
|
|
@@ -3286,16 +3277,16 @@ var component_catalog_default = {
|
|
|
3286
3277
|
},
|
|
3287
3278
|
{
|
|
3288
3279
|
name: "DataTablePagination",
|
|
3289
|
-
description: "Pagination controls for
|
|
3280
|
+
description: "Pagination controls for DataTable with page navigation and rows per page selector",
|
|
3290
3281
|
category: "data",
|
|
3291
3282
|
importPath: "@classic-homes/theme-svelte",
|
|
3292
3283
|
props: [
|
|
3293
3284
|
{
|
|
3294
3285
|
name: "table",
|
|
3295
|
-
type: "
|
|
3286
|
+
type: "DataTableInstance<T>",
|
|
3296
3287
|
default: "**required**",
|
|
3297
3288
|
required: false,
|
|
3298
|
-
description: "The
|
|
3289
|
+
description: "The table instance from createDataTable"
|
|
3299
3290
|
},
|
|
3300
3291
|
{
|
|
3301
3292
|
name: "pageSizeOptions",
|
|
@@ -3330,7 +3321,7 @@ var component_catalog_default = {
|
|
|
3330
3321
|
examples: [
|
|
3331
3322
|
{
|
|
3332
3323
|
title: "Basic Usage",
|
|
3333
|
-
code: "<script>\n import { createDataTable, DataTablePagination } from '@classic-homes/theme-svelte';\n\n const
|
|
3324
|
+
code: "<script>\n import { createDataTable, DataTablePagination } from '@classic-homes/theme-svelte';\n\n const table = createDataTable(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n }));\n</script>\n\n<table>...</table>\n<DataTablePagination {table} />"
|
|
3334
3325
|
},
|
|
3335
3326
|
{
|
|
3336
3327
|
title: "Custom Page Sizes",
|
|
@@ -3358,10 +3349,10 @@ var component_catalog_default = {
|
|
|
3358
3349
|
props: [
|
|
3359
3350
|
{
|
|
3360
3351
|
name: "table",
|
|
3361
|
-
type: "
|
|
3352
|
+
type: "DataTableInstance<T>",
|
|
3362
3353
|
default: "**required**",
|
|
3363
3354
|
required: false,
|
|
3364
|
-
description: "The
|
|
3355
|
+
description: "The table instance from createDataTable"
|
|
3365
3356
|
},
|
|
3366
3357
|
{
|
|
3367
3358
|
name: "placeholder",
|
|
@@ -3396,7 +3387,7 @@ var component_catalog_default = {
|
|
|
3396
3387
|
examples: [
|
|
3397
3388
|
{
|
|
3398
3389
|
title: "Basic Usage",
|
|
3399
|
-
code: "<script>\n import { createDataTable, DataTableSearch } from '@classic-homes/theme-svelte';\n\n let globalFilter = $state('');\n\n const
|
|
3390
|
+
code: "<script>\n import { createDataTable, DataTableSearch } from '@classic-homes/theme-svelte';\n\n let globalFilter = $state('');\n\n const table = createDataTable(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n onGlobalFilterChange: (filter) => {\n globalFilter = filter;\n },\n }));\n</script>\n\n<DataTableSearch {table} /><table>...</table>"
|
|
3400
3391
|
},
|
|
3401
3392
|
{
|
|
3402
3393
|
title: "Custom Placeholder",
|
|
@@ -3435,10 +3426,10 @@ var component_catalog_default = {
|
|
|
3435
3426
|
props: [
|
|
3436
3427
|
{
|
|
3437
3428
|
name: "table",
|
|
3438
|
-
type: "
|
|
3429
|
+
type: "DataTableInstance<T>",
|
|
3439
3430
|
default: "**required**",
|
|
3440
3431
|
required: false,
|
|
3441
|
-
description: "The
|
|
3432
|
+
description: "The table instance from createDataTable"
|
|
3442
3433
|
},
|
|
3443
3434
|
{
|
|
3444
3435
|
name: "showSearch",
|
|
@@ -3461,12 +3452,6 @@ var component_catalog_default = {
|
|
|
3461
3452
|
required: false,
|
|
3462
3453
|
description: "Placeholder text for search input"
|
|
3463
3454
|
},
|
|
3464
|
-
{
|
|
3465
|
-
name: "visibilityState",
|
|
3466
|
-
type: "VisibilityState",
|
|
3467
|
-
required: false,
|
|
3468
|
-
description: "Optional visibility state for reactivity"
|
|
3469
|
-
},
|
|
3470
3455
|
{
|
|
3471
3456
|
name: "filters",
|
|
3472
3457
|
type: "Snippet",
|
|
@@ -3498,7 +3483,7 @@ var component_catalog_default = {
|
|
|
3498
3483
|
examples: [
|
|
3499
3484
|
{
|
|
3500
3485
|
title: "Basic Usage",
|
|
3501
|
-
code: "<script>\n import { createDataTable, DataTableToolbar } from '@classic-homes/theme-svelte';\n\n const
|
|
3486
|
+
code: "<script>\n import { createDataTable, DataTableToolbar } from '@classic-homes/theme-svelte';\n\n const table = createDataTable(() => ({\n data: users,\n columns,\n getRowId: (row) => String(row.id),\n }));\n</script>\n\n<DataTableToolbar {table} /><table>...</table>"
|
|
3502
3487
|
},
|
|
3503
3488
|
{
|
|
3504
3489
|
title: "Search Only",
|
|
@@ -3548,10 +3533,10 @@ var component_catalog_default = {
|
|
|
3548
3533
|
props: [
|
|
3549
3534
|
{
|
|
3550
3535
|
name: "table",
|
|
3551
|
-
type: "
|
|
3536
|
+
type: "DataTableInstance<T>",
|
|
3552
3537
|
default: "**required**",
|
|
3553
3538
|
required: false,
|
|
3554
|
-
description: "The
|
|
3539
|
+
description: "The table instance from createDataTable"
|
|
3555
3540
|
},
|
|
3556
3541
|
{
|
|
3557
3542
|
name: "rowHeight",
|
|
@@ -3563,7 +3548,7 @@ var component_catalog_default = {
|
|
|
3563
3548
|
{
|
|
3564
3549
|
name: "overscan",
|
|
3565
3550
|
type: "number",
|
|
3566
|
-
default: "
|
|
3551
|
+
default: "10",
|
|
3567
3552
|
required: false,
|
|
3568
3553
|
description: "Number of rows to render outside visible area"
|
|
3569
3554
|
},
|
|
@@ -3580,13 +3565,6 @@ var component_catalog_default = {
|
|
|
3580
3565
|
required: false,
|
|
3581
3566
|
description: "Callback when row is clicked"
|
|
3582
3567
|
},
|
|
3583
|
-
{
|
|
3584
|
-
name: "enableRowSelection",
|
|
3585
|
-
type: "boolean",
|
|
3586
|
-
default: "false",
|
|
3587
|
-
required: false,
|
|
3588
|
-
description: "Enable row selection checkboxes"
|
|
3589
|
-
},
|
|
3590
3568
|
{
|
|
3591
3569
|
name: "class",
|
|
3592
3570
|
type: "string",
|
|
@@ -3609,13 +3587,12 @@ var component_catalog_default = {
|
|
|
3609
3587
|
code: `<script>
|
|
3610
3588
|
import { createDataTable, DataTableVirtual } from '@classic-homes/theme-svelte';
|
|
3611
3589
|
|
|
3612
|
-
const
|
|
3590
|
+
const table = createDataTable(() => ({
|
|
3613
3591
|
data: largeDataset, // 10,000+ rows
|
|
3614
3592
|
columns,
|
|
3593
|
+
getRowId: (row) => String(row.id),
|
|
3615
3594
|
manualPagination: true, // Disable pagination for virtualization
|
|
3616
3595
|
}));
|
|
3617
|
-
|
|
3618
|
-
const table = $derived(tableApi.instance);
|
|
3619
3596
|
</script>
|
|
3620
3597
|
|
|
3621
3598
|
<DataTableVirtual {table} height="600px" />`
|
|
@@ -3627,7 +3604,7 @@ var component_catalog_default = {
|
|
|
3627
3604
|
{
|
|
3628
3605
|
title: "With More Overscan",
|
|
3629
3606
|
description: "For smoother scrolling, increase the overscan:",
|
|
3630
|
-
code: '<DataTableVirtual {table} overscan={
|
|
3607
|
+
code: '<DataTableVirtual {table} overscan={15} height="600px" />'
|
|
3631
3608
|
},
|
|
3632
3609
|
{
|
|
3633
3610
|
title: "With Row Click Handler",
|
|
@@ -3635,22 +3612,7 @@ var component_catalog_default = {
|
|
|
3635
3612
|
},
|
|
3636
3613
|
{
|
|
3637
3614
|
title: "With Row Selection",
|
|
3638
|
-
code:
|
|
3639
|
-
let rowSelection = $state({});
|
|
3640
|
-
|
|
3641
|
-
const tableApi = createDataTable(() => ({
|
|
3642
|
-
data: largeDataset,
|
|
3643
|
-
columns,
|
|
3644
|
-
state: { rowSelection },
|
|
3645
|
-
onRowSelectionChange: (updater) => {
|
|
3646
|
-
rowSelection = typeof updater === 'function' ? updater(rowSelection) : updater;
|
|
3647
|
-
},
|
|
3648
|
-
enableRowSelection: true,
|
|
3649
|
-
manualPagination: true,
|
|
3650
|
-
}));
|
|
3651
|
-
</script>
|
|
3652
|
-
|
|
3653
|
-
<DataTableVirtual {table} enableRowSelection height="600px" />`
|
|
3615
|
+
code: '<script>\n let rowSelection = $state<Set<string>>(new Set());\n\n const table = createDataTable(() => ({\n data: largeDataset,\n columns,\n getRowId: (row) => String(row.id),\n manualPagination: true,\n onRowSelectionChange: (selection) => {\n rowSelection = selection;\n },\n }));\n</script>\n\n<DataTableVirtual {table} height="600px" />'
|
|
3654
3616
|
},
|
|
3655
3617
|
{
|
|
3656
3618
|
title: "Full Height Container",
|
|
@@ -4419,69 +4381,6 @@ var component_catalog_default = {
|
|
|
4419
4381
|
"Button"
|
|
4420
4382
|
]
|
|
4421
4383
|
},
|
|
4422
|
-
{
|
|
4423
|
-
name: "FlexRender",
|
|
4424
|
-
description: "Dynamic content renderer for TanStack Table cells and headers",
|
|
4425
|
-
category: "data",
|
|
4426
|
-
importPath: "@classic-homes/theme-svelte",
|
|
4427
|
-
props: [
|
|
4428
|
-
{
|
|
4429
|
-
name: "content",
|
|
4430
|
-
type: "unknown",
|
|
4431
|
-
default: "**required**",
|
|
4432
|
-
required: false,
|
|
4433
|
-
description: "Content to render (string, component, or function)"
|
|
4434
|
-
},
|
|
4435
|
-
{
|
|
4436
|
-
name: "props",
|
|
4437
|
-
type: "TProps",
|
|
4438
|
-
default: "**required**",
|
|
4439
|
-
required: false,
|
|
4440
|
-
description: "Props to pass to component or function"
|
|
4441
|
-
},
|
|
4442
|
-
{
|
|
4443
|
-
name: "asComponent",
|
|
4444
|
-
type: "boolean",
|
|
4445
|
-
default: "false",
|
|
4446
|
-
required: false,
|
|
4447
|
-
description: "Explicitly mark content as a Svelte component"
|
|
4448
|
-
}
|
|
4449
|
-
],
|
|
4450
|
-
variants: [],
|
|
4451
|
-
slots: [
|
|
4452
|
-
{
|
|
4453
|
-
name: "children",
|
|
4454
|
-
description: "Main content",
|
|
4455
|
-
required: false
|
|
4456
|
-
}
|
|
4457
|
-
],
|
|
4458
|
-
events: [],
|
|
4459
|
-
examples: [
|
|
4460
|
-
{
|
|
4461
|
-
title: "Basic Usage",
|
|
4462
|
-
code: "<script>\n import { createDataTable, FlexRender } from '@classic-homes/theme-svelte';\n\n const tableApi = createDataTable(() => ({ data: users, columns }));\n const table = $derived(tableApi.instance);\n</script>\n\n<table>\n <thead>\n {#each table.getHeaderGroups() as headerGroup}\n <tr>\n {#each headerGroup.headers as header}\n <th>\n <FlexRender content={header.column.columnDef.header} props={header.getContext()} />\n </th>\n {/each}\n </tr>\n {/each}\n </thead>\n <tbody>\n {#each table.getRowModel().rows as row}\n <tr>\n {#each row.getVisibleCells() as cell}\n <td>\n <FlexRender content={cell.column.columnDef.cell} props={cell.getContext()} />\n </td>\n {/each}\n </tr>\n {/each}\n </tbody>\n</table>"
|
|
4463
|
-
},
|
|
4464
|
-
{
|
|
4465
|
-
title: "With Custom Cell Component",
|
|
4466
|
-
code: `<!-- StatusBadge.svelte -->
|
|
4467
|
-
<script lang="ts">
|
|
4468
|
-
import type { CellContext } from '@classic-homes/theme-svelte';
|
|
4469
|
-
import Badge from './Badge.svelte';
|
|
4470
|
-
|
|
4471
|
-
let { getValue }: CellContext<User, string> = $props();
|
|
4472
|
-
const status = $derived(getValue());
|
|
4473
|
-
</script>
|
|
4474
|
-
|
|
4475
|
-
<Badge variant={status === 'active' ? 'success' : 'secondary'}>
|
|
4476
|
-
{status}
|
|
4477
|
-
</Badge>`
|
|
4478
|
-
}
|
|
4479
|
-
],
|
|
4480
|
-
relatedComponents: [
|
|
4481
|
-
"DataTable",
|
|
4482
|
-
"DataTableEditableCell"
|
|
4483
|
-
]
|
|
4484
|
-
},
|
|
4485
4384
|
{
|
|
4486
4385
|
name: "Footer",
|
|
4487
4386
|
description: "Site footer with link sections and branding",
|
|
@@ -10584,7 +10483,7 @@ var token_definitions_default = {
|
|
|
10584
10483
|
name: "charcoal",
|
|
10585
10484
|
description: "Collection - Charcoal gray",
|
|
10586
10485
|
shades: {
|
|
10587
|
-
"50": "#
|
|
10486
|
+
"50": "#fafafa",
|
|
10588
10487
|
"100": "#e6e6e6",
|
|
10589
10488
|
"200": "#cccccc",
|
|
10590
10489
|
"300": "#b3b3b3",
|