import React from 'react'; import type { CollectionEditorProps } from '../../../../types/collection-editor'; import { Button } from '../../../button/public'; import { IconButton } from '../../../button/public'; import { Card } from '../../../card/public'; import { View } from '../../../layout/public'; import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope'; import { Text } from '../../../typography/public'; function CollectionEditorInner({ themeId: _themeId, mode: _mode, title, description, items, renderItem, onAdd, onRemove, onMove, addLabel = 'Add Item', emptyLabel = 'No items yet.', disabled, testID, interactionPolicy, }: CollectionEditorProps) { const isEmpty = items.length === 0; return ( {addLabel} ) : null } > {isEmpty ? ( {emptyLabel} ) : ( items.map((item, index) => ( {renderItem({ item, index, remove: () => onRemove?.(index), moveUp: () => onMove?.(index, index - 1), moveDown: () => onMove?.(index, index + 1), canMoveUp: index > 0, canMoveDown: index < items.length - 1, })} {onMove ? ( <> onMove(index, index - 1)} size="s" variant="ghost" /> onMove(index, index + 1)} size="s" variant="ghost" /> ) : null} {onRemove ? ( onRemove(index)} size="s" variant="ghost" /> ) : null} )) )} ); } /*** * Editor pattern for adding, removing, and reordering a collection of items. * */ export const CollectionEditor = withZoraThemeScope(CollectionEditorInner);