Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.
TypeScript fintechinvoiceinvoice-generatorinvoice-pdfinvoice-templateinvoicesnextjsopen-sourcequotesreactreact-pdf-rendererself-hostedshadcn-uitailwindcsstypescript
feat: store pdf fonts locally, adjust styles to prevent input focus on iOS (#57)
Vlad Sazonau0ac78846d13b
diff --git a/public/fonts/open-sans-700.ttf b/public/fonts/open-sans-700.ttfnew file mode 100644index 0000000..fd79d43Binary files /dev/null and b/public/fonts/open-sans-700.ttf differdiff --git a/public/fonts/open-sans-regular.ttf b/public/fonts/open-sans-regular.ttfnew file mode 100644index 0000000..db43334Binary files /dev/null and b/public/fonts/open-sans-regular.ttf differdiff --git a/src/app/components/invoice-form.tsx b/src/app/components/invoice-form.tsxindex bc04cdb..11cf66c 100644--- a/src/app/components/invoice-form.tsx+++ b/src/app/components/invoice-form.tsx@@ -621,7 +621,7 @@ export function InvoiceForm({invoiceData={invoiceData}/></div>- <div className="space-y-4">+ <div className="mt-5 space-y-4"><div><Label htmlFor="sellerName" className="mb-1">Name@@ -1789,27 +1789,47 @@ export function InvoiceForm({{/* Payment Due */}<div>- <Label htmlFor="paymentDue" className="mb-1">- Payment Due- </Label>- <Controller- name="paymentDue"- control={control}- render={({ field }) => (- <Input {...field} id="paymentDue" type="date" className="" />+ <div className="mb-6">+ <Label htmlFor="paymentDue" className="mb-1">+ Payment Due+ </Label>+ <Controller+ name="paymentDue"+ control={control}+ render={({ field }) => (+ <Input {...field} id="paymentDue" type="date" className="" />+ )}+ />+ {errors.paymentDue && (+ <ErrorMessage>{errors.paymentDue.message}</ErrorMessage>)}- />- {errors.paymentDue && (- <ErrorMessage>{errors.paymentDue.message}</ErrorMessage>- )}- {!errors.paymentDue && isPaymentDueBeforeDateOfIssue ? (- <InputHelperMessage>- <span className="flex items-center text-balance">- <AlertIcon />- Payment due date is before date of issue (- {dayjs(dateOfIssue).format("DD.MM.YYYY")})- </span>+ {!errors.paymentDue && isPaymentDueBeforeDateOfIssue ? (+ <InputHelperMessage>+ <span className="flex items-center text-balance">+ <AlertIcon />+ Payment due date is before date of issue (+ {dayjs(dateOfIssue).format("DD.MM.YYYY")})+ </span>+ <ButtonHelper+ onClick={() => {+ const newPaymentDue = dayjs(dateOfIssue)+ .add(14, "days")+ .format("YYYY-MM-DD");++ setValue("paymentDue", newPaymentDue);+ }}+ >+ Click to set payment due date 14 days after the date of issue+ ({dayjs(dateOfIssue).add(14, "days").format("DD/MM/YYYY")})+ </ButtonHelper>+ </InputHelperMessage>+ ) : null}+ {/* If there are no errors and the payment due date is not before the date of issue and the payment due date is not 14 days after the date of issue, show the button to set the payment due date to 14 days after the date of issue (probably a bit better UX) */}+ {!errors.paymentDue &&+ !isPaymentDueBeforeDateOfIssue &&+ !isPaymentDue14DaysFromDateOfIssue ? (<ButtonHelper+ className="whitespace-normal"onClick={() => {const newPaymentDue = dayjs(dateOfIssue).add(14, "days")@@ -1821,30 +1841,12 @@ export function InvoiceForm({Click to set payment due date 14 days after the date of issue ({dayjs(dateOfIssue).add(14, "days").format("DD/MM/YYYY")})</ButtonHelper>- </InputHelperMessage>- ) : null}- {/* If there are no errors and the payment due date is not before the date of issue and the payment due date is not 14 days after the date of issue, show the button to set the payment due date to 14 days after the date of issue (probably a bit better UX) */}- {!errors.paymentDue &&- !isPaymentDueBeforeDateOfIssue &&- !isPaymentDue14DaysFromDateOfIssue ? (- <ButtonHelper- className="whitespace-normal"- onClick={() => {- const newPaymentDue = dayjs(dateOfIssue)- .add(14, "days")- .format("YYYY-MM-DD");-- setValue("paymentDue", newPaymentDue);- }}- >- Click to set payment due date 14 days after the date of issue (- {dayjs(dateOfIssue).add(14, "days").format("DD/MM/YYYY")})- </ButtonHelper>- ) : null}+ ) : null}+ </div></div>{/* Notes */}- <div className="mb-4">+ <div className=""><div className="relative mb-2 flex items-center justify-between"><Label htmlFor="notes" className="">Notesdiff --git a/src/app/components/invoice-pdf-template/index.tsx b/src/app/components/invoice-pdf-template/index.tsxindex 391bd9c..d7c4cf8 100644--- a/src/app/components/invoice-pdf-template/index.tsx+++ b/src/app/components/invoice-pdf-template/index.tsx@@ -28,10 +28,10 @@ Font.register({family: fontFamily,fonts: [{- src: "https://cdn.jsdelivr.net/npm/[email protected]/fonts/open-sans-regular.ttf",+ src: "/fonts/open-sans-regular.ttf",},{- src: "https://cdn.jsdelivr.net/npm/[email protected]/fonts/open-sans-700.ttf",+ src: "/fonts/open-sans-700.ttf",fontWeight: 700,},],diff --git a/src/app/error.tsx b/src/app/error.tsxindex 1f7c5a0..0ceec08 100644--- a/src/app/error.tsx+++ b/src/app/error.tsx@@ -96,10 +96,10 @@ export default function Error({function ErrorMessage({ children }: { children: React.ReactNode }) {return (- <div className="rounded-lg border border-red-500/50 px-4 py-3 text-red-600">+ <div className="mx-5 rounded-lg border border-red-500/50 px-4 py-3 text-red-600"><p className="text-sm"><CircleAlert- className="-mt-0.5 me-3 inline-flex opacity-60"+ className="-mt-0.5 me-2 inline-flex opacity-60"size={16}strokeWidth={2}aria-hidden="true"diff --git a/src/app/layout.tsx b/src/app/layout.tsxindex ee51665..ccb7b3a 100644--- a/src/app/layout.tsx+++ b/src/app/layout.tsx@@ -1,10 +1,17 @@-import type { Metadata } from "next";+import type { Metadata, Viewport } from "next";import { NuqsAdapter } from "nuqs/adapters/next/app";import { OpenPanelComponent } from "@openpanel/nextjs";import "./globals.css";import { Toaster } from "sonner";+export const viewport: Viewport = {+ initialScale: 1, // Sets the default zoom level to 1 (100%)+ width: "device-width", // Ensures the viewport width matches the device's screen width+ maximumScale: 1, // Prevents users from zooming in+ viewportFit: "cover", // Enables edge-to-edge content display on devices with rounded corners (like iPhones with a notch)+};+export const metadata: Metadata = {title: "Free PDF Invoice Generator with Live Preview",description:diff --git a/src/components/seller-management.tsx b/src/components/seller-management.tsxindex b6dddff..8743c8c 100644--- a/src/components/seller-management.tsx+++ b/src/components/seller-management.tsx@@ -1,6 +1,5 @@import { Plus, Trash2, Pencil } from "lucide-react";-import { Label } from "@radix-ui/react-label";// import { Info } from "lucide-react";import { useId, useState, useEffect } from "react";import { CustomTooltip } from "./ui/tooltip";@@ -27,6 +26,7 @@ import {import { z } from "zod";import { toast } from "sonner";import { cn } from "@/lib/utils";+import { Label } from "./ui/label";export const SELLERS_LOCAL_STORAGE_KEY = "EASY_INVOICE_PDF_SELLERS";@@ -177,7 +177,7 @@ export function SellerManagement({{sellers.length > 0 ? (<div className="space-y-1"><div className="flex items-center gap-1">- <Label htmlFor={sellerSelectId} className="text-[12px]">+ <Label htmlFor={sellerSelectId} className="">Select Seller</Label></div>@@ -185,7 +185,7 @@ export function SellerManagement({<SelectNativeid={sellerSelectId}className={cn(- "block h-8 max-w-[200px] text-[12px] lg:text-[12px]",+ "block h-8 max-w-[200px] text-[12px]",!selectedSellerIndex && "italic text-gray-700")}onChange={handleSellerChange}diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsxindex d4ff4be..4205ad7 100644--- a/src/components/ui/dialog.tsx+++ b/src/components/ui/dialog.tsx@@ -22,7 +22,7 @@ const DialogOverlay = React.forwardRef<ref={ref}className={cn("fixed inset-0 z-[101] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",- className,+ className)}{...props}/>@@ -38,13 +38,13 @@ const DialogContent = React.forwardRef<<DialogPrimitive.Contentref={ref}className={cn(- "fixed left-1/2 top-1/2 z-[101] grid max-h-[calc(100%-4rem)] w-full -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto border border-slate-200 bg-white p-6 shadow-lg shadow-black/5 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:max-w-[400px] sm:rounded-xl dark:border-slate-800 dark:bg-slate-950",- className,+ "fixed left-1/2 top-1/2 z-[101] grid max-h-[calc(100%-4rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-xl border border-slate-200 bg-white p-6 shadow-lg shadow-black/5 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] dark:border-slate-800 dark:bg-slate-950 sm:max-w-[400px] sm:rounded-xl",+ className)}{...props}>{children}- <DialogPrimitive.Close className="group absolute right-3 top-3 flex size-7 items-center justify-center rounded-lg outline-offset-2 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring/70 disabled:pointer-events-none">+ <DialogPrimitive.Close className="focus-visible:outline-ring/70 group absolute right-3 top-3 flex size-7 items-center justify-center rounded-lg outline-offset-2 transition-colors focus-visible:outline focus-visible:outline-2 disabled:pointer-events-none"><Xsize={16}strokeWidth={2}@@ -57,14 +57,29 @@ const DialogContent = React.forwardRef<));DialogContent.displayName = DialogPrimitive.Content.displayName;-const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (- <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />+const DialogHeader = ({+ className,+ ...props+}: React.HTMLAttributes<HTMLDivElement>) => (+ <div+ className={cn(+ "flex flex-col space-y-1.5 text-center sm:text-left",+ className+ )}+ {...props}+ />);DialogHeader.displayName = "DialogHeader";-const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (+const DialogFooter = ({+ className,+ ...props+}: React.HTMLAttributes<HTMLDivElement>) => (<div- className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end sm:gap-3", className)}+ className={cn(+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end sm:gap-3",+ className+ )}{...props}/>);diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsxindex 6785c88..4302513 100644--- a/src/components/ui/input.tsx+++ b/src/components/ui/input.tsx@@ -8,7 +8,7 @@ const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(type={type}autoComplete="off"className={cn(- "h-8 w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-[1rem] text-slate-950 shadow-sm shadow-black/5 transition-shadow placeholder:text-slate-500/70 focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 dark:placeholder:text-slate-400/70 dark:focus-visible:border-slate-300 dark:focus-visible:ring-slate-300/20 lg:text-sm",+ "h-8 w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-slate-950 shadow-sm shadow-black/5 transition-shadow placeholder:text-slate-500/70 focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 dark:placeholder:text-slate-400/70 dark:focus-visible:border-slate-300 dark:focus-visible:ring-slate-300/20",type === "search" &&"[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none",type === "file" &&diff --git a/src/components/ui/select-native.tsx b/src/components/ui/select-native.tsxindex da8af3b..9c2c08a 100644--- a/src/components/ui/select-native.tsx+++ b/src/components/ui/select-native.tsx@@ -16,7 +16,7 @@ const SelectNative = React.forwardRef<HTMLSelectElement, SelectPropsNative>(<div className="relative"><selectclassName={cn(- "peer mt-1 block w-full cursor-pointer appearance-none items-center rounded-md border border-gray-300 bg-white text-[1rem] text-slate-950 shadow-sm shadow-black/5 transition-shadow focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 has-[option[disabled]:checked]:text-slate-500 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 dark:focus-visible:border-slate-300 dark:focus-visible:ring-slate-300/20 dark:has-[option[disabled]:checked]:text-slate-400 lg:text-sm",+ "peer mt-1 block w-full cursor-pointer appearance-none items-center rounded-md border border-gray-300 bg-white text-sm text-slate-950 shadow-sm shadow-black/5 transition-shadow focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 has-[option[disabled]:checked]:text-slate-500 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 dark:focus-visible:border-slate-300 dark:focus-visible:ring-slate-300/20 dark:has-[option[disabled]:checked]:text-slate-400",props.multiple? "py-1 [&>*]:px-3 [&>*]:py-1 [&_option:checked]:bg-slate-100 dark:[&_option:checked]:bg-slate-800": "h-9 pe-8 ps-3",diff --git a/src/components/ui/textarea.tsx b/src/components/ui/textarea.tsxindex a6f3641..976e717 100644--- a/src/components/ui/textarea.tsx+++ b/src/components/ui/textarea.tsx@@ -9,7 +9,7 @@ const Textarea = React.forwardRef<return (<textareaclassName={cn(- "flex min-h-[80px] w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-[1rem] text-slate-950 shadow-sm shadow-black/5 transition-shadow placeholder:text-slate-500/70 focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 dark:placeholder:text-slate-400/70 dark:focus-visible:border-slate-300 dark:focus-visible:ring-slate-300/20 lg:text-sm",+ "flex min-h-[80px] w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm text-slate-950 shadow-sm shadow-black/5 transition-shadow placeholder:text-slate-500/70 focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 dark:placeholder:text-slate-400/70 dark:focus-visible:border-slate-300 dark:focus-visible:ring-slate-300/20",className)}ref={ref}