///
import { type Cell, Default, handler, recipe, UI } from "commontools";
interface FriendListState {
names: Default;
}
const removeItem = handler; index: number }>(
(_, { names, index }) => {
const currentNames = names.get();
names.set(currentNames.toSpliced(index, 1));
},
);
const editItem = handler; index: number }>(
(event, { names, index }) => {
if (event?.key === "Enter") {
const newValue = event?.target?.value;
if (newValue !== undefined) {
const currentNames = names.get();
names.set(currentNames.toSpliced(index, 1, newValue));
}
}
},
);
export default recipe("making lists - with edit", (state) => {
return {
[UI]: (
),
names: state.names,
};
});