import React, {useState, memo} from 'react' import {IconColumn4, IconColumn2, IconColumn2Alt, MaterialIconTextFormat} from '@karma.run/icons' import {centerLayoutDecorator} from '../.storybook/decorators' import {BlockList, BlockListValue, useBlockMap} from './blockList' import {Grid, Column} from '../layout/grid' import {PlaceholderInput} from '../input/placeholderInput' import {Box} from '../layout/box' import {BlockProps} from './block' import {TextInput} from '../input/textInput' export type StringValue = BlockListValue<'string', string> export type WrapperValue = StringValue export default { component: BlockList, title: 'Blocks|BlockList', decorators: [centerLayoutDecorator(0.8)] } export const Default = () => { const [values, setValues] = useState([ {key: '1', type: 'string', value: 'Hello'}, {key: '2', type: 'string', value: 'World'} ]) return ( {useBlockMap( () => ({ string: { field: props => , defaultValue: '', label: 'String', icon: MaterialIconTextFormat } }), [] )} ) } export const WithGrid = () => { const [values, setValues] = useState([ {key: '1', type: 'column2', value: []}, {key: '2', type: 'column4', value: []}, {key: '3', type: 'column2Alt', value: []} ]) return ( {{ column4: { field: props => ( ), defaultValue: [], label: '4 Cols', icon: IconColumn4 }, column2: { field: props => ( ), defaultValue: [], label: '2 Cols', icon: IconColumn2 }, column2Alt: { field: props => ( ), defaultValue: [], label: '2 Cols Alt', icon: IconColumn2Alt } }} ) } export const Disabled = () => { const [values, setValues] = useState([ {key: '1', type: 'string', value: 'Hello'}, {key: '2', type: 'string', value: 'World'} ]) return ( {useBlockMap( () => ({ string: { field: props => , defaultValue: '', label: 'String', icon: MaterialIconTextFormat } }), [] )} ) } const TextInputBlock = memo(({value, onChange, disabled}: BlockProps) => { return ( { onChange(e.currentTarget.value) }} /> ) })