import type { Meta, StoryObj } from '@storybook/vue3' import FdsTableHead from '../FdsTableHead/FdsTableHead.vue' import FdsTable from './FdsTable.vue' const meta: Meta = { title: 'FDS/Table/FdsTable', component: FdsTable, tags: ['autodocs'], argTypes: { bordered: { control: { type: 'boolean' } }, compact: { control: { type: 'boolean' } }, }, args: { bordered: false, compact: false, }, } export default meta type Story = StoryObj const tableTransform = (storyContext: { args?: { bordered?: boolean; compact?: boolean } }) => { const args = storyContext?.args || {} const attrs = [] if (args.bordered) attrs.push(':bordered="true"') if (args.compact) attrs.push(':compact="true"') const attrsStr = attrs.length ? ` ${attrs.join(' ')}` : '' return ` IDNamnE-postRoll
{{ row.id }} {{ row.name }} {{ row.email }} {{ row.role }}
` } const sampleData = [ { id: 1, name: 'Anna Andersson', email: 'anna@example.com', role: 'Admin' }, { id: 2, name: 'Erik Eriksson', email: 'erik@example.com', role: 'User' }, { id: 3, name: 'Maria Svensson', email: 'maria@example.com', role: 'User' }, { id: 4, name: 'Lars Larsson', email: 'lars@example.com', role: 'Moderator' }, ] export const Default: Story = { render: (args: Story['args']) => ({ components: { FdsTable, FdsTableHead }, setup: () => ({ args, sampleData }), template: ` IDNamnE-postRoll
{{ row.id }} {{ row.name }} {{ row.email }} {{ row.role }}
`, }), parameters: { docs: { source: { transform: tableTransform, }, }, }, } export const Bordered: Story = { args: { bordered: true }, render: (args: Story['args']) => ({ components: { FdsTable, FdsTableHead }, setup: () => ({ args, sampleData }), template: ` IDNamnE-postRoll
{{ row.id }} {{ row.name }} {{ row.email }} {{ row.role }}
`, }), parameters: { docs: { source: { transform: tableTransform, }, }, }, } export const Compact: Story = { args: { compact: true }, render: (args: Story['args']) => ({ components: { FdsTable, FdsTableHead }, setup: () => ({ args, sampleData }), template: ` IDNamnE-postRoll
{{ row.id }} {{ row.name }} {{ row.email }} {{ row.role }}
`, }), parameters: { docs: { source: { transform: tableTransform, }, }, }, } export const Sortable: Story = { render: () => ({ components: { FdsTable, FdsTableHead }, setup: () => ({ sampleData }), template: ` IDNamnE-postRoll
{{ row.id }} {{ row.name }} {{ row.email }} {{ row.role }}
`, }), parameters: { docs: { source: { code: ` IDNamnE-postRoll
{{ row.id }} {{ row.name }} {{ row.email }} {{ row.role }}
`, }, }, }, }