import * as React from 'react' import type { StoryObj, Meta } from '@storybook/react-webpack5' import { GridEditorInputNumeric } from '.' import { Grid } from '../grids' import { GridCellDefault } from '../components' import { Arrange } from '@planview/pv-icons' import { theme } from '@planview/pv-utilities' import type { GridConfirmPayload } from '../types' import type { InputType } from '@storybook/csf' const hideControl: InputType = { control: false } export default { title: 'pv-grid/Components/Editors/GridEditorInputNumeric', component: GridEditorInputNumeric, parameters: { controls: { exclude: ['label', 'mode', 'rowId', 'columnId'], }, }, argTypes: { columnId: hideControl, rowId: hideControl, tabIndex: hideControl, value: hideControl, }, } satisfies Meta type NumberRow = { id: string input: number } export const Default: StoryObj = { render: function Component(args) { const [rows, setRows] = React.useState([ { id: '1', input: 2300 }, { id: '2', input: 5600 }, { id: '3', input: 34566 }, ]) return ( ) } else { return ( ) } }, Editor(props) { return ( ) }, }, }, ]} rows={rows} onCellChange={( confirm: GridConfirmPayload< NumberRow, 'input', string, number > ) => { setRows((r) => r.map((row) => { if (row.id === confirm.rowId) { return { ...row, input: Number(confirm.nextValue), } } return row }) ) }} /> ) }, args: { placeholder: 'This is a placeholder', icon: 'no icon' as any, }, argTypes: { icon: { control: { type: 'radio' }, options: ['no icon', 'with icon', 'with coloured icon'], mapping: { 'no icon': null, 'with icon': , 'with coloured icon': , }, }, }, parameters: { docs: { source: { code: ` const [rows, setRows] = React.useState([ { id: '1', input: 2300 }, { id: '2', input: 5600 }, { id: '3', input: 34566 }, ]) return ( ) } else { return } }, Editor(props) { return ( ) }, }, }, ]} rows={rows} onCellChange={( confirm: GridConfirmPayload< NumberRow, 'input', string, number > ) => { setRows((r) => r.map((row) => { if (row.id === confirm.rowId) { return { ...row, input: Number(confirm.nextValue), } } return row }) ) }} /> ) `, }, }, }, }