Files
ADS3-Design-System/src/components/atoms/Autocomplete/Autocomplete.stories.tsx
Richie d915443b8c Align design system with ADS 3.0 and add new components
Token foundation: fix 16 palette colours to match official ADS_COLORS,
add 5 new palettes (teal, brown, purple, fuchsia, yellow), realign
semantic tokens (primary=navy, info=bright blue), fix border radii to
8px base, add responsive heading typography.

Component migration: swap primary/info references across all existing
components, update Button (44px/semibold), Switch (green/compact),
Chip (30px/8px radius + colour variants), SideNav (80px rail), Tag
(11 colours).

New components: SideNav, TopBar, Avatar, Tabs, PageHeader, Slider,
RangeSlider, FileInput, DataTable, List, Autocomplete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-03 14:24:23 +10:00

92 lines
2.0 KiB
TypeScript

import type { Meta, StoryObj } from '@storybook/react'
import { useState } from 'react'
import { Autocomplete } from './Autocomplete'
const states = [
{ value: 'nsw', label: 'New South Wales' },
{ value: 'vic', label: 'Victoria' },
{ value: 'qld', label: 'Queensland' },
{ value: 'wa', label: 'Western Australia' },
{ value: 'sa', label: 'South Australia' },
{ value: 'tas', label: 'Tasmania' },
{ value: 'act', label: 'Australian Capital Territory' },
{ value: 'nt', label: 'Northern Territory' },
]
const meta: Meta<typeof Autocomplete> = {
title: 'Atoms/Autocomplete',
component: Autocomplete,
tags: ['autodocs'],
parameters: { layout: 'padded' },
}
export default meta
type Story = StoryObj<typeof Autocomplete>
const BasicTemplate = () => {
const [value, setValue] = useState('')
return (
<div className="w-96">
<Autocomplete
label="State"
placeholder="Search states…"
options={states}
value={value}
onChange={setValue}
/>
</div>
)
}
export const Default: Story = {
render: () => <BasicTemplate />,
}
const FreeSoloTemplate = () => {
const [value, setValue] = useState('')
return (
<div className="w-96">
<Autocomplete
label="School name"
placeholder="Type to search or enter a new name…"
options={states}
value={value}
onChange={setValue}
freeSolo
hint="Select from the list or type a custom value"
/>
</div>
)
}
export const FreeSolo: Story = {
name: 'Free solo (Combobox)',
render: () => <FreeSoloTemplate />,
}
export const WithError: Story = {
name: 'With error',
render: () => (
<div className="w-96">
<Autocomplete
label="State"
options={states}
error="Please select a valid state"
/>
</div>
),
}
export const Disabled: Story = {
render: () => (
<div className="w-96">
<Autocomplete
label="State"
options={states}
value="nsw"
disabled
/>
</div>
),
}