import type { Meta, StoryObj } from '@storybook/nextjs' import { useState } from 'react' import { InputNumber } from '.' const meta = { title: 'Base/InputNumber', component: InputNumber, parameters: { layout: 'centered', docs: { description: { component: 'Number input component with increment/decrement buttons. Supports min/max constraints, custom step amounts, and units display.', }, }, }, tags: ['autodocs'], argTypes: { value: { control: 'number', description: 'Current value', }, size: { control: 'select', options: ['regular', 'large'], description: 'Input size', }, min: { control: 'number', description: 'Minimum value', }, max: { control: 'number', description: 'Maximum value', }, amount: { control: 'number', description: 'Step amount for increment/decrement', }, unit: { control: 'text', description: 'Unit text displayed (e.g., "px", "ms")', }, disabled: { control: 'boolean', description: 'Disabled state', }, defaultValue: { control: 'number', description: 'Default value when undefined', }, }, } satisfies Meta export default meta type Story = StoryObj // Interactive demo wrapper const InputNumberDemo = (args: any) => { const [value, setValue] = useState(args.value ?? 0) return (
{ setValue(newValue) console.log('Value changed:', newValue) }} />
Current value: {value}
) } // Default state export const Default: Story = { render: args => , args: { value: 0, size: 'regular', }, } // Large size export const LargeSize: Story = { render: args => , args: { value: 10, size: 'large', }, } // With min/max constraints export const WithMinMax: Story = { render: args => , args: { value: 5, min: 0, max: 10, size: 'regular', }, } // With custom step amount export const CustomStepAmount: Story = { render: args => , args: { value: 50, amount: 5, min: 0, max: 100, size: 'regular', }, } // With unit export const WithUnit: Story = { render: args => , args: { value: 100, unit: 'px', min: 0, max: 1000, amount: 10, size: 'regular', }, } // Disabled state export const Disabled: Story = { render: args => , args: { value: 42, disabled: true, size: 'regular', }, } // Decimal values export const DecimalValues: Story = { render: args => , args: { value: 2.5, amount: 0.5, min: 0, max: 10, size: 'regular', }, } // Negative values allowed export const NegativeValues: Story = { render: args => , args: { value: 0, min: -100, max: 100, amount: 10, size: 'regular', }, } // Size comparison const SizeComparisonDemo = () => { const [regularValue, setRegularValue] = useState(10) const [largeValue, setLargeValue] = useState(20) return (
) } export const SizeComparison: Story = { render: () => , } // Real-world example - Font size picker const FontSizePickerDemo = () => { const [fontSize, setFontSize] = useState(16) return (

Preview Text

) } export const FontSizePicker: Story = { render: () => , } // Real-world example - Quantity selector const QuantitySelectorDemo = () => { const [quantity, setQuantity] = useState(1) const pricePerItem = 29.99 const total = (quantity * pricePerItem).toFixed(2) return (

Product Name

${pricePerItem} each

Total ${total}
) } export const QuantitySelector: Story = { render: () => , } // Real-world example - Timer settings const TimerSettingsDemo = () => { const [hours, setHours] = useState(0) const [minutes, setMinutes] = useState(15) const [seconds, setSeconds] = useState(30) const totalSeconds = hours * 3600 + minutes * 60 + seconds return (

Timer Configuration

Total duration: {totalSeconds} seconds
) } export const TimerSettings: Story = { render: () => , } // Real-world example - Animation settings const AnimationSettingsDemo = () => { const [duration, setDuration] = useState(300) const [delay, setDelay] = useState(0) const [iterations, setIterations] = useState(1) return (

Animation Properties

animation: {duration}ms {delay}ms {iterations}
) } export const AnimationSettings: Story = { render: () => , } // Real-world example - Temperature control const TemperatureControlDemo = () => { const [temperature, setTemperature] = useState(20) const fahrenheit = ((temperature * 9) / 5 + 32).toFixed(1) return (

Temperature Control

Celsius
{temperature}°C
Fahrenheit
{fahrenheit}°F
) } export const TemperatureControl: Story = { render: () => , } // Interactive playground export const Playground: Story = { render: args => , args: { value: 10, size: 'regular', min: 0, max: 100, amount: 1, unit: '', disabled: false, defaultValue: 0, }, }