Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

sharedForm.ts

38 lines881 Bytes

1export type TodoId = string
2​
3export type TodoItem = {
4 id: TodoId
5 label: string
6}
7​
8export const initialItems: Array<TodoItem> = [
9 { id: 'todo-1', label: 'Collect requirements' },
10 { id: 'todo-2', label: 'Sketch the flow' },
11 { id: 'todo-3', label: 'Wire the form' },
12 { id: 'todo-4', label: 'Polish interactions' },
14​
15export const initialDoneItems: Array<TodoItem> = [
16 { id: 'todo-5', label: 'Review accessibility' },
17 { id: 'todo-6', label: 'Ship example' },
19​
20const itemGroups = ['items', 'doneItems'] as const
21​
22export type ItemGroup = (typeof itemGroups)[number]
23​
24export const itemGroupLabels: Record<ItemGroup, string> = {
25 items: 'Planning',
26 doneItems: 'Done',
28​
29let nextId = initialItems.length + initialDoneItems.length + 1
30​
31export function createItem(): TodoItem {
32 const id = nextId++
33​
34 return {
35 id: `todo-${id}`,
36 label: `New item ${id}`,
37 }