import type { Meta, StoryObj } from '@storybook/vue3'; import { ref } from 'vue'; import TitanIconSelect from './TitanIconSelect.vue'; const meta = { component: TitanIconSelect, title: 'UI/TitanIconSelect', tags: ['autodocs'], argTypes: { modelValue: { control: 'text', description: 'The currently selected option value (v-model)', table: { type: { summary: 'string' }, }, }, options: { control: 'object', description: 'Array of option objects with value and label properties', table: { type: { summary: 'IconSelectOption[]' }, }, }, name: { control: 'text', description: 'Name attribute for the radio input group', table: { type: { summary: 'string' }, }, }, disabled: { control: 'boolean', description: 'Whether the entire select is disabled', table: { type: { summary: 'boolean' }, defaultValue: { summary: false }, }, }, required: { control: 'boolean', description: 'Whether selection is required', table: { type: { summary: 'boolean' }, defaultValue: { summary: false }, }, }, error: { control: 'boolean', description: 'Whether the select has an error state', table: { type: { summary: 'boolean' }, defaultValue: { summary: false }, }, }, showCheckmark: { control: 'boolean', description: 'Whether to show a checkmark (✓) on the selected option\'s label', table: { type: { summary: 'boolean' }, defaultValue: { summary: false }, }, }, 'onUpdate:modelValue': { action: 'update:modelValue', description: 'Emitted when selection changes', table: { category: 'Events', type: { summary: '(value: string) => void' }, }, }, }, } satisfies Meta; export default meta; type Story = StoryObj; /** * Default memorialization preference selector with three options. * Each option displays an icon (via slot) and a label. */ export const Default: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref(''); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'other', label: 'Other' }, ], }, }; /** * Icon select with a pre-selected value. */ export const WithValue: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref('buried'); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'other', label: 'Other' }, ], }, }; /** * Icon select with checkmark displayed on selected option. */ export const WithCheckmark: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref('cremated'); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'other', label: 'Other' }, ], showCheckmark: true, }, }; /** * Icon select with only two options. */ export const TwoOptions: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref(''); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, ], }, }; /** * Icon select with four options to test layout. */ export const FourOptions: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref(''); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'memorial', label: 'Memorial' }, { value: 'other', label: 'Other' }, ], }, }; /** * Disabled state - entire select is disabled. */ export const Disabled: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref(''); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'other', label: 'Other' }, ], disabled: true, }, }; /** * Disabled state with a pre-selected value. */ export const DisabledWithValue: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref('cremated'); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'other', label: 'Other' }, ], disabled: true, }, }; /** * Required field with validation. */ export const Required: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref(''); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'other', label: 'Other' }, ], required: true, }, }; /** * Error state showing validation failure. */ export const WithError: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref(''); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'other', label: 'Other' }, ], required: true, error: true, }, }; /** * Interactive playground with all controls. */ export const Playground: Story = { render: (args) => ({ components: { TitanIconSelect }, setup() { const value = ref(''); return { args, value }; }, template: ` `, }), args: { name: 'memorialization', options: [ { value: 'buried', label: 'Buried' }, { value: 'cremated', label: 'Cremated' }, { value: 'other', label: 'Other' }, ], disabled: false, required: false, error: false, }, };