diff --git a/src/components/wordpress/DataViews.stories.tsx b/src/components/wordpress/DataViews.stories.tsx index 947a66f..bdcbee2 100644 --- a/src/components/wordpress/DataViews.stories.tsx +++ b/src/components/wordpress/DataViews.stories.tsx @@ -17,18 +17,35 @@ interface User { } // Generate sample data +const firstNames = [ + "James", "Emma", "Liam", "Olivia", "Noah", "Ava", "William", "Sophia", + "Benjamin", "Isabella", "Lucas", "Mia", "Henry", "Charlotte", "Alexander", + "Amelia", "Daniel", "Harper", "Matthew", "Evelyn", "Sebastian", "Aria", + "Jack", "Chloe", "Owen", +]; +const lastNames = [ + "Anderson", "Martinez", "Thompson", "Garcia", "Robinson", "Clark", "Lewis", + "Walker", "Hall", "Young", "King", "Wright", "Lopez", "Hill", "Scott", + "Green", "Adams", "Baker", "Nelson", "Carter", "Mitchell", "Perez", + "Roberts", "Turner", "Phillips", +]; + const generateUsers = (count: number): User[] => { const statuses: User["status"][] = ["active", "inactive", "pending"]; const roles = ["Admin", "Editor", "Viewer", "Manager"]; - - return Array.from({ length: count }, (_, i) => ({ - id: `user-${i + 1}`, - name: `User ${i + 1}`, - email: `user${i + 1}@example.com`, - status: statuses[i % 3], - role: roles[i % 4], - joinedAt: new Date(2024, i % 12, (i % 28) + 1).toLocaleDateString(), - })); + + return Array.from({ length: count }, (_, i) => { + const first = firstNames[i % firstNames.length]; + const last = lastNames[i % lastNames.length]; + return { + id: `user-${i + 1}`, + name: `${first} ${last}`, + email: `${first.toLowerCase()}.${last.toLowerCase()}@example.com`, + status: statuses[i % 3], + role: roles[i % 4], + joinedAt: new Date(2024, i % 12, (i % 28) + 1).toLocaleDateString(), + }; + }); }; const allUsers = generateUsers(100); @@ -959,80 +976,24 @@ FullFeatured.storyName = "Full Featured"; */ function PosterGrid({ items }: { items: User[] }) { return ( -
+
{items.map((item) => (
-
-

+
+

{item.name}

-

+

{item.email}

-
- +
+ {item.role} - + {item.status}
@@ -1083,9 +1044,8 @@ export const LayoutCustomComponent: StoryFn = () => { view={view} fields={fields} onChangeView={setView} - defaultLayouts={{ table: {} }} > -
+
{DataViews.Search && }
diff --git a/src/components/wordpress/dataviews.tsx b/src/components/wordpress/dataviews.tsx index c328d99..220000a 100644 --- a/src/components/wordpress/dataviews.tsx +++ b/src/components/wordpress/dataviews.tsx @@ -228,7 +228,7 @@ const FilterItems = ({ return ( -
+
{activeFilters.map((id) => { const field = fields.find((f) => f.id === id); @@ -368,27 +368,63 @@ const ListEmpty = ({ icon, description, title }: ListEmptyProps) => { }; /** - * Renders a skeleton table with real column headers and animated placeholder rows. + * Renders a skeleton loading state matching the current view type. */ function SkeletonTable({ rows, headers, hasActions, - hasBulkActions + hasBulkActions, + viewType = 'table' }: { rows: number; headers: string[]; hasActions: boolean; hasBulkActions: boolean; + viewType?: string; }) { + if (viewType === 'grid') { + return ( +
+ {Array.from({ length: rows }, (_, i) => ( +
+ + + +
+ + +
+
+ ))} +
+ ); + } + + if (viewType === 'list') { + return ( +
+ {Array.from({ length: rows }, (_, i) => ( +
+
+ + +
+ {hasActions && } +
+ ))} +
+ ); + } + const widths = ['w-3/4', 'w-1/2', 'w-2/3', 'w-5/6', 'w-2/5']; return ( - + {hasBulkActions && ( - )} @@ -398,7 +434,7 @@ function SkeletonTable({ {Array.from({ length: rows }, (_, rowIdx) => ( - + {hasBulkActions && (
+ {label} @@ -409,7 +445,7 @@ function SkeletonTable({
@@ -710,7 +746,7 @@ export function DataViews(props: DataViewsProps) { {header &&
{header}
}
@@ -796,6 +832,7 @@ export function DataViews(props: DataViewsProps) { )} {isLoading ? (