export interface Todo {
id: string;
title: string;
done: boolean;
pending: boolean;
}
import { useEffect, useRef } from "react";
const FOCUSABLE = [
"a[href]",
"button:not([disabled])",
"textarea:not([disabled])",
import { z } from 'zod';
export const signupSchema = z
.object({
email: z.string().min(1, 'Email is required').email('Enter a valid email'),
password: z
export const FLAG_REGISTRY = {
newDashboard: {
default: false as boolean,
description: 'Renders the redesigned dashboard shell',
},
maxUploadMb: {
import { z } from "zod";
export const signupSchema = z
.object({
email: z.string().min(1, "Email is required").email("Enter a valid email"),
username: z
export const required = (msg = 'This field is required') => (value) =>
value && value.trim() !== '' ? '' : msg;
export const minLength = (n, msg) => (value) =>
value && value.length >= n ? '' : msg || `Must be at least ${n} characters`;
import { useCallback, useEffect, useState } from "react";
type Patch = Record<string, string | null | undefined>;
function readParams(): URLSearchParams {
return new URLSearchParams(window.location.search);
import React, { useState, useEffect, useCallback, useMemo, useRef, useContext } from 'react';
// 1. useState - managing component state
function Counter() {
const [count, setCount] = useState(0);
const [name, setName] = useState('');
export function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
export function move(list, from, to) {
const next = list.slice();
import { useReducer, useCallback } from 'react';
const initialState = (present) => ({ past: [], present, future: [] });
function historyReducer(state, action) {
const { past, present, future } = state;
export const initialState = (steps, initialData = {}) => ({
steps,
stepIndex: 0,
data: initialData,
errors: {},
});
export const wizardMachine = {
initial: 'account',
states: {
account: {
next: 'profile',
canLeave: (data) => Boolean(data.email && data.password),